OleDbCommand Selecting Variable Data

Discussion in 'ASP General' started by Jason Steeves, Jun 27, 2005.

  1. -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
    Jason Steeves, Jun 27, 2005
    #1
    1. Advertising

  2. Jason Steeves wrote:
    > -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
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jun 27, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel

    OleDbDataAdapter vs OleDbCommand

    darrel, Nov 23, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,933
    Scott M.
    Nov 25, 2005
  2. Tom Wild
    Replies:
    0
    Views:
    388
    Tom Wild
    Aug 21, 2003
  3. Simon Harris
    Replies:
    1
    Views:
    345
    DalePres
    Jan 31, 2005
  4. =?Utf-8?B?SmFzb24gU3RlZXZlcw==?=

    OleDbCommand Selecting Variable Data

    =?Utf-8?B?SmFzb24gU3RlZXZlcw==?=, Jun 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    491
    =?Utf-8?B?SmFzb24gU3RlZXZlcw==?=
    Jun 27, 2005
  5. Mark Sandfox

    Problem with OleDBCommand Update

    Mark Sandfox, Jul 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,008
    Balder78
    Aug 13, 2008
Loading...

Share This Page