Results 1 to 6 of 6

Thread: [RESOLVED] erro in insert colon from textbox to DBaccess

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2004
    Location
    syria
    Posts
    854

    Resolved [RESOLVED] erro in insert colon from textbox to DBaccess

    Here is a code to insert data to DBaccess from textbox. When I write a colon(') in the textbox to add to DB it caused error and show me this Message "Syntax error in string in query expression '''')'

    vb Code:
    1. Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" _
    2.        & "Data Source =" & Application.StartupPath & "\Store.mdb ")
    3.         Dim cmd As New OleDbCommand
    4.         cmd.Connection = conn
    5.  
    6.         'Add text to DB
    7.         cmd.CommandText = "INSERT INTO TBinMaterial(inMaterial)  " & "values ('" & txtAddM.Text & "')  "
    8.         cmd.CommandType = CommandType.Text
    9.         conn.Open()
    10.         cmd.ExecuteNonQuery()
    11.         conn.Close()
    Last edited by nader; Oct 12th, 2008 at 09:02 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width