OleDbCommand Selecting Variable Data

J

Jason Steeves

-Dim cmd As OleDbCommand
-cmd = New OleDbCommand("select * from qmsstats where firstname='jason'",
OleDbConnection1)
-OleDbDataAdapter2.SelectCommand = cmd
-DataGrid1.Visible = True
-OleDbDataAdapter2.Fill(DsQmsStats1)
-DataGrid1.DataBind()

In the above example I need to change 'jason' to a variable. I need the
variable to be pulled from a textbox. IE: txtusername.text. Please advise how
I can get the value from txtusername.text in place of 'jason'.

Thanks, Jason Steeves
 
B

Bob Barrows [MVP]

Jason said:
-Dim cmd As OleDbCommand
-cmd = New OleDbCommand("select * from qmsstats where
firstname='jason'", OleDbConnection1)
-OleDbDataAdapter2.SelectCommand = cmd
-DataGrid1.Visible = True
-OleDbDataAdapter2.Fill(DsQmsStats1)
-DataGrid1.DataBind()

In the above example I need to change 'jason' to a variable. I need
the variable to be pulled from a textbox. IE: txtusername.text.
Please advise how I can get the value from txtusername.text in place
of 'jason'.

There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-savvy person here who can
answer your question, you can eliminate the luck factor by posting your
question to a newsgroup where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.

You need to use a parameter marker, "?", and use the OleDbCommand's
parameters collection to pass the value from the textbox to the parameter
marker. If you have Visual Studio, you can look these concepts up in online
help. If not, go to msdn.microsoft.com/library and search for "parameter
queries" or "parameter markers"

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top