dcsimg
Results 1 to 3 of 3

Thread: How do I use variables in a SQL statement in vb.net 2008

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Question How do I use variables in a SQL statement in vb.net 2008

    I got this in my SQL statement. I "BOLDED" the problem.

    Code:
    SELECT OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry FROM Orders 
    WHERE CustomerID = @CustomerID
    I saw a video tutorial on the internet, http://msdn.microsoft.com/en-us/vbasic/cc138242.aspx where they are doing this. The example that I inserted is actually from the tutoral. For some reason it wont work on my side.

    How do I use variables in a SQL statement?

  2. #2
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Re: How do I use variables in a SQL statement in vb.net 2008

    suppose you want the value of @CustomerID to be the value inputted by the user in textbox1,then:

    Code:
    OledbCommandObject.Parameters.AddWithValue("@CustomerID",textbox1.text)
    Last edited by gautamshaw; Apr 16th, 2010 at 06:27 AM.

    If you find my reply helpful , then rate it

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,879

    Re: How do I use variables in a SQL statement in vb.net 2008

    Follow the Blog link in my signature about Parameters in ADO.NET for more information.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width