my command is
delete table1 from table1, table2 where table1.test = table2.test
please help
i keep getting
delete is not declared so i tryed this
Dim
delete As New SqlCommand()delete table1 from table1, table2 where table1.test = table2.test
now i get delete isnt an expression please help
willing to change anything to get this to work

sql commands in visual basic express 2005
Maurice Maglalang
do you know of any way to run that command when i hit a button on the screen
thanks
Emil Prager
habnix
your delete-statement is wrong. The syntax is:
this page (http://www.w3schools.com/sql) may be very helpful, when learning sql.
What exactly do you need only the sql statemen or some lines of VB code
Please tell us what you want to delete in your tables, if you need further assistance.
djjos
-- from the link --
Version 1.1 of SqlClient introduced a regression in the handling of connection strings that contain apostrophes (') or double quotation marks (""). This causes connection strings with correctly escaped apostrophes or double quotation marks to fail, and you receive the following error message:
paraGOD
try this link: MSDN SqlCommand.ExecuteNonQuery
In your on_click button event add this code
----------------
Dim strCnn As String = "Your Connection String"
Dim strSQL as String = "Delete From Server where Server IN (SELECT Product1 FROM Customer)"
CreateCommand(strCnn, strCnn)
----------------
Then add this sub (copied from the link above)
Public Sub CreateCommand(ByVal queryString As String, ByVal connectionString As String)
Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
command.Connection.Open()
command.ExecuteNonQuery()
End Using
End Sub
Also add:
Imports System.Data.SqlClient
To the top of your .vb file
Javelin
Jivitesh
i got that but when i use this code it states delete isnt declared
Delete From Server where Server IN (SELECT Product1 FROM Customer);
please help
trogers
In the designer:
1) Add a button to the page.
2) Double click the button to open the on_click event handler code.
3) Place the code you wish to execute in the on_click event handler.
4) Compile and test.
stefan__
Imports
System.Data.SqlClientPublic
Class Form2 Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strCnn As String = "C:\Documents and Settings\Justin\My Documents\Visual Studio 2005\Projects\Inventory Systems1\Inventory Systems1\Inventory.mdf" Dim strSQL As String = "Delete From Server where Server IN (SELECT Product1 FROM Customer);"CreateCommand(strCnn, strCnn)
End Sub Public Sub CreateCommand(ByVal queryString As String, ByVal connectionString As String) Using connection As New SqlConnection(connectionString) Dim command As New SqlCommand(queryString, connection)command.Connection.Open()
command.ExecuteNonQuery()
End Using End SubEnd
ClassChakshu
visual basic 2005
net framework 2
it doesnt say anything about these also i cant figure out how to download it
please help
mcfin
format of initialization string does not conform to specification starting at index 0
thanks
GTH
The Sql-command is: "Delete FROM table1 where (searchcondtion................"
If you are deleting based on values from another table:
"Delete From Table1 where test IN (SELECT Test FROM Table2);"
By that you are taking all the values in Table2.field("Test") and If they also are in Table1.field("Test"), you delete them in Table1.
Hope it helps
RoseyA
but i still having trouble with delete not being declared
can someone please help me
i know its some vb code
but i cant figure it out