securonic
Active member
Hi everyone,
i have put together some code to execute a search on a specific columb in a sql server database. very simple really and it will be used as part of a larger system eventually
little problem though.....
Public Class Form1
Private Sub sb1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sb1.Click
Dim con As New SqlClient.SqlConnection()
con.ConnectionString = "Data Source=213.***.***.1;Initial Catalog=clients;Persist Security Info=True;User ID=tom;Password=jones"
Dim cmd As New SqlCommand
Dim sqlstr As String
sqlstr = "SELECT * FROM clients WHERE name=" & "'" & textbox.Text & "'"
cmd.CommandText = sqlstr
cmd.Connection = con
Try
con.Open()
cmd.ExecuteNonQuery()
Finally
con.Close()
End Try
End Sub
Private Sub con(ByVal p1 As Object)
Throw New NotImplementedException
End Sub
End Class
only problem is i seem to be getting a problem when the line that executes the sql command string returns an exception 'invalid object name 'clients'. can anyone lend a hand in what this means?? been searching the net for a while now and still scratching my bonce.
many thanks
i have put together some code to execute a search on a specific columb in a sql server database. very simple really and it will be used as part of a larger system eventually
little problem though.....
Public Class Form1
Private Sub sb1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sb1.Click
Dim con As New SqlClient.SqlConnection()
con.ConnectionString = "Data Source=213.***.***.1;Initial Catalog=clients;Persist Security Info=True;User ID=tom;Password=jones"
Dim cmd As New SqlCommand
Dim sqlstr As String
sqlstr = "SELECT * FROM clients WHERE name=" & "'" & textbox.Text & "'"
cmd.CommandText = sqlstr
cmd.Connection = con
Try
con.Open()
cmd.ExecuteNonQuery()
Finally
con.Close()
End Try
End Sub
Private Sub con(ByVal p1 As Object)
Throw New NotImplementedException
End Sub
End Class
only problem is i seem to be getting a problem when the line that executes the sql command string returns an exception 'invalid object name 'clients'. can anyone lend a hand in what this means?? been searching the net for a while now and still scratching my bonce.
many thanks