I have code below which i use to select data from sql database table using dataadapter but i throws an error:
"Must declare the scalar variable"@UserName"
Where is the mistake in code????
I have tried the code below which throws an error "Must declare the scalar variable"@UserName"
Dim Query as string ="SELECT *FROM UserLogins WHERE [Login Name]=
@Username AND Password=@passcode"
// add parameters to dataadapter select command
SQL.da.SelectCommand.Parameters.AddWithValue("@Username", "%" +
txtuserName.Text + "%")
SQL.da.SelectCommand.Parameters.AddWithValue("@passcode", "%" +
txtpasslogin.Text + "%")
//execute query and fill dataset
da = New SqlDataAdapter(Query,Con)
cb = New SqlCommandBuilder(da)
ds = New DataSet
da.Fill(ds)
Datagridview1.Datasource=ds.tables(0)