Avatar of Sivasan
SivasanFlag for United States of America

asked on 

Update syntex in a VB.Net when using a string where clause

Hi THERE
I have made an application in VB.net 2003.
I have a button to update a table in Ms access .
When I give a string from the text box as parametr for the the where clause. I get a syntex error.
For example
On the Textbox in my form I give a value 1693
on the click of the button.
i get Syntex error in data in querry expression 'LD=# 1693#"
LD is a text field in my access table
My code is as seen below. Not sure if I'm passing the string correctly. Please advice.

 Private Sub YesToALLLoadBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YesToALLLoadBTN.Click
        Try

            Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\TEXASSCH\WACO  USE.mdb"
            Dim myConnection As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection
            myConnection.ConnectionString = connString

            myConnection.Open()
                    Dim stSQL As String = "UPDATE [USER ENTRY] SET  ShipYes = 0 where LD =  #" & OTBOX.Text & "# "

            Dim cmd As New System.Data.OleDb.OleDbCommand(stSQL, myConnection)

            cmd.ExecuteNonQuery()

            myConnection.Close()
           

        Catch ex As Exception
            'MsgBox(" The Changes That You Made To Missed Order Has Been Saved")
            MsgBox(ex.Message + vbCrLf + ex.Source & vbCrLf & vbCrLf & ex.StackTrace, MsgBoxStyle.Critical, "Error")
        End Try

    End Sub
.NET ProgrammingMicrosoft AccessVisual Basic.NET

Avatar of undefined
Last Comment
Sivasan
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Dim stSQL As String
stSQL = "UPDATE [USER ENTRY] SET  ShipYes = 0 where LD =  '" & OTBOX.Text & "'"
SOLUTION
Avatar of jefftwilley
jefftwilley
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of JunnickYso
JunnickYso
Flag of Philippines image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
JunnickYso,
this is from the the question above
 >>>>     LD is a text field in my access table
Avatar of Sivasan
Sivasan
Flag of United States of America image

ASKER

Dear Capricorn,Jeff, Junnick:
Thank you all for your reply. Capricorn's anwser worked great. I split the points a bit Cap -400( He was the first to reply)
Jeff-50 Junnick- 50 as all of you gave the correct answer and gave extra information
which was very useful.
Thanks a million to all you guys!
S
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo