1
How can I declare @NIF as a string
Dim sqlConString As String = "Server=localhost\TESTE;Database=tempTest;User Id=sa;Password=123"
Dim conn = New SqlConnection(sqlConString)
Try
Conn.Open()
Dim strSQL As String = "SELECT * From Computador Where Nifcliente = @NIF"
conn.Close()
Dim da As New SqlDataAdapter(strSQL, Conn)
Dim ds As New DataSet
da.Fill(ds, "Computador")
DataGrid.DataSource = ds.Tables(0)
Catch ex As SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
As it is a single value it would not be simpler to do so:
"SELECT * From Computador Where Nifcliente = '" + nif + "'"
, beingnif
the variable string with the value?– Ricardo Pontual