hi every 1 i am trying to make a search form . i want to display the data saved in sql server in a grid view upon hiting the search button . below is the code which i am using but i am getting an error > Conversion failed when converting the varchar value 'anees' to data type int..please can some one help or modify my code
Dim mycon As New SqlClient.SqlConnection("Data Source=SAAD-PC\SQLEXPRESS;Initial Catalog=photoshoot;Integrated Security=True")
mycon.Open()
Dim cmd As String
cmd = "select * from staff where staff.LastName=" & Val(txtEmpSearchLastName.Text)
Dim da As New SqlDataAdapter(cmd, mycon)
Dim dt As New DataTable
da.Fill(dt)
If dt.Rows.Count = 0 Then
MsgBox("no records found.")
End If
DataGridView1.DataSource = dt
mycon.Close()
End Sub