While updating it passes parameters with updatecommand from dataset
How can it be done in selectcommand
passing parameters from dataset ?
Printable View
While updating it passes parameters with updatecommand from dataset
How can it be done in selectcommand
passing parameters from dataset ?
try explaining yourself a litle bit more :-)
or post your code..
I mean before loading data I want to type in the textboxes
and use these as crietria from select command
Hi!
The dataadapter has a SelectCommand and the selectcommand has a parameter collection. So either add the parameter in design time or at run time and change the selectcommand to include a WHERE clause like "WHERE ContractID = @ContractID" where @ContractID is the name of the parameter.
Ofcourse you also have to pass a value to the parameter before trying to fill the dataset.
/NisseCode:daContract.SelectCommand.Parameters("@ContractID").Value = txtContractID.Text
Yes I did so but it is not accepting the parameters
Did you define the parameter first?
Either by "dim":ing it, and adding it to the parameters collection? or selecting the data-adapter, check the selectcommand property and there create a parameter?
I made the changes in sql statement
select * from ......
where fld1=?....
and it autometically created the parameter but it gave error that it couldn't bind to the parameter?
How about something like this..
I find that parameters work better using the SqlClient.SqlCommand instead of the OLEDB.OLEDBCommandCode:Public Sub SelectRecords()
Dim MyConnection As New SqlClient.SqlConnection
Dim myCommand As New SqlClient.SqlCommand
myCommand.Parameters.Add(New SqlClient.SqlParameter("@CustomerID", TextBox1.Text))
myCommand.CommandText = "SELECT * FROM MyTable WHERE CustomerID=@CustomerID"
myCommand.Connection = MyConnection
End Sub
HTH
Thanks .
It works fine.but it gives error if I use master detail relationed form.