I am using the following SQL statement :
Dim strSql5 As String = "SELECT * FROM dbo.ontledings " & _
" where plaasblok = @plaasblokparsversoeke " & _
" and analisedatum = @laastedatum"
cnn.Open()
Dim aksie2 As New SqlClient.SqlCommand(strSql5, cnn)
aksie2.Parameters.Add("@plaasblokparsversoeke", SqlDbType.VarChar).Value = plaasblokparsversoeke
aksie2.Parameters.Add("@laastedatum", SqlDbType.Date).Value = laastedatum
aksie2.ExecuteNonQuery()
cnn.Close()
I want to fill a datatable like so :
Dim dtb5 As New DataTable
dtb5.Clear()
Using cnn As New SqlConnection("Data Source=GIDEON-E-LAPTOP\SQLEXPRESS2014;Initial Catalog=SkeduleringDatabasis;Integrated Security=True")
cnn.Open()
Using dad5 As New SqlDataAdapter(strSql5, cnn)
dad5.Fill(dtb5)
End Using
cnn.Close()
End Using
I get the following error message : Must declare the scalar variable "@plaasblokparsversoeke"
I cannot figure out where and how to declare the scalar variables.
The error occurs at the line : dad5.Fill(dtb5)
Regards