|
-
Mar 25th, 2004, 08:42 AM
#1
Thread Starter
Addicted Member
passing parameters in selectcommand
While updating it passes parameters with updatecommand from dataset
How can it be done in selectcommand
passing parameters from dataset ?
-
Mar 26th, 2004, 03:43 AM
#2
Junior Member
try explaining yourself a litle bit more :-)
or post your code..
-
Mar 26th, 2004, 04:07 AM
#3
Thread Starter
Addicted Member
passing parameters in selectcommand
I mean before loading data I want to type in the textboxes
and use these as crietria from select command
-
Mar 26th, 2004, 04:13 AM
#4
Member
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.
Code:
daContract.SelectCommand.Parameters("@ContractID").Value = txtContractID.Text
/Nisse
-
Mar 28th, 2004, 11:53 PM
#5
Thread Starter
Addicted Member
passing parameters in selectcommand
Yes I did so but it is not accepting the parameters
-
Mar 29th, 2004, 02:45 AM
#6
Member
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?
-
Mar 29th, 2004, 07:23 AM
#7
Thread Starter
Addicted Member
passing parameters in selectcommand
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?
-
Mar 29th, 2004, 04:07 PM
#8
Hyperactive Member
How about something like this..
Code:
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
I find that parameters work better using the SqlClient.SqlCommand instead of the OLEDB.OLEDBCommand
HTH
-
Mar 29th, 2004, 11:59 PM
#9
Thread Starter
Addicted Member
passing parameters in selectcommand
Thanks .
It works fine.but it gives error if I use master detail relationed form.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|