troubleshooting Question

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

Avatar of Sivasan
SivasanFlag for United States of America asked on
Microsoft Access.NET ProgrammingVisual Basic.NET
6 Comments1 Solution220 ViewsLast Modified:
I have made an application in 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

            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

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

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



        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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros