Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6612091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:03:15+00:00 2026-05-25T20:03:15+00:00

I am working on part of a application that needs to import data from

  • 0

I am working on part of a application that needs to import data from a excel sheet into a mysql database table. The code works fine until it gets to a record in the excel sheet where one of the string values gets assigned “ABCDE All’John D Doe 999 West Lame Blvd Cullman, AL 35055”. I am not certain but I believe that it has to do completely with the “‘” that appears there. Which that can not change and other records from the excelsheet could contain the ” ‘ ” as well… When it gets to this record it throws this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘John D Doe’,’ABCDE’,’All’John’,’D’,’Doe’,’256-555-5555′,’ ‘,’256-555-5555’ at line 1

the code that i have around this problems is as follows:

        Private Function PerFormUpdate(ByVal customer As String, ByVal bill_to As String, ByVal Contact As String, ByVal Company As String, ByVal firstName As String, ByVal mi As String, ByVal lastname As String, ByVal phone As String, ByVal altPhone As String, ByVal fax As String)
        Dim _db As New schoolEntities

        Dim command As MySqlCommand = _dbconn.CreateCommand()
        command.CommandText = "SELECT * FROM quickbooks_imports WHERE Customer= "" &  _customer& "" & Bill_to= "" & _bill_to& "" & Contact= "" & _Company& ""& First_Name= "" & _firstName& "" & M_I= "" & _mi& "" & Last_Name= "" & _lastname& "" & Phone= "" & _phone& "" & Alt_Phone= "" & _altPhone& "" & Fax= "" & _Fax& """
        _dbconn.Open()

        Dim _mysqlReader As MySqlDataReader = command.ExecuteReader()
        _dbconn.Close()

        If Not _mysqlReader.HasRows Then
            Dim _UpdateItem As New quickbooks_imports
            Dim updateCommand As MySqlCommand = _dbconn.CreateCommand()

            _UpdateItem.Customer = customer
            _UpdateItem.Bill_to = bill_to
            _UpdateItem.Contact = Contact
            _UpdateItem.Company = Company
            _UpdateItem.First_Name = firstName
            _UpdateItem.M_I = mi
            _UpdateItem.Last_Name = lastname
            _UpdateItem.Phone = phone
            _UpdateItem.Alt_Phone = altPhone
            _UpdateItem.Fax = fax

            updateCommand.CommandText = "INSERT INTO quickbooks_imports(Customer,Bill_to,Contact,Company,First_Name,M_I,Last_Name,Phone,Alt_Phone,Fax) VALUES ('" & _UpdateItem.Customer & "','" & _UpdateItem.Bill_to & "','" & _UpdateItem.Contact & "','" & _UpdateItem.Company & "','" & _UpdateItem.First_Name & "','" & _UpdateItem.M_I & "','" & _UpdateItem.Last_Name & "','" & _UpdateItem.Phone & "','" & _UpdateItem.Alt_Phone & "','" & _UpdateItem.Fax & "') "
            _dbconn.Open()
            updateCommand.ExecuteNonQuery()

            _db.SaveChanges()

The Error shows up on the ExecuteNonQuery to perform the update..

Any help would be greatly appreciated…

As per your response I switched to the params and this is the new code:

            updateCommand.CommandText = "INSERT INTO quickbooks_imports (Customer,Bill_to,Contact,Company,First_Name,M_I,Last_Name,Phone,Alt_Phone,Fax) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"
            updateCommand.Parameters.AddWithValue("Customer", _UpdateItem.Customer)
            updateCommand.Parameters.AddWithValue("Bill_to", _UpdateItem.Bill_to)
            updateCommand.Parameters.AddWithValue("Contact", _UpdateItem.Contact)
            updateCommand.Parameters.AddWithValue("Company", _UpdateItem.Company)
            updateCommand.Parameters.AddWithValue("First_Name", _UpdateItem.First_Name)
            updateCommand.Parameters.AddWithValue("M_I", _UpdateItem.M_I)
            updateCommand.Parameters.AddWithValue("Last_Name", _UpdateItem.Last_Name)
            updateCommand.Parameters.AddWithValue("Phone", _UpdateItem.Phone)
            updateCommand.Parameters.AddWithValue("Alt_Phone", _UpdateItem.Alt_Phone)
            updateCommand.Parameters.AddWithValue("Fax", _UpdateItem.Fax)

how ever its throwing a fatal exception now…

I just tried using name parameters as you mentioned in your reply and the code is as follows:

            Private Function PerFormUpdate(ByVal customer As String, ByVal bill_to As String, ByVal Contact As String, ByVal Company As String, ByVal firstName As String, ByVal mi As String, ByVal lastname As String, ByVal phone As String, ByVal altPhone As String, ByVal fax As String)
        Dim _db As New schoolEntities

        Dim command As MySqlCommand = _dbconn.CreateCommand()
        command.CommandText = "SELECT * FROM quickbooks_imports WHERE Customer= "" & _customer& "" & Bill_to= "" & _bill_to& "" & Contact= "" & _Company& ""& First_Name= "" & _firstName& "" & M_I= "" & _mi& "" & Last_Name= "" & _lastname& "" & Phone= "" & _phone& "" & Alt_Phone= "" & _altPhone& "" & Fax= "" & _Fax& """
        _dbconn.Open()

        Dim _mysqlReader As MySqlDataReader = command.ExecuteReader()
        _dbconn.Close()

        If Not _mysqlReader.HasRows Then
            Dim _UpdateItem As New quickbooks_imports
            Dim updateCommand As MySqlCommand = _dbconn.CreateCommand()

            _UpdateItem.Customer = customer
            _UpdateItem.Bill_to = bill_to
            _UpdateItem.Contact = Contact
            _UpdateItem.Company = Company
            _UpdateItem.First_Name = firstName
            _UpdateItem.M_I = mi
            _UpdateItem.Last_Name = lastname
            _UpdateItem.Phone = phone
            _UpdateItem.Alt_Phone = altPhone
            _UpdateItem.Fax = fax

            updateCommand.CommandText = "INSERT INTO quickbooks_imports (Customer,Bill_to,Contact,Company,First_Name,M_I,Last_Name,Phone,Alt_Phone,Fax) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
            updateCommand.Parameters.AddWithValue("@Customer", _UpdateItem.Customer)
            updateCommand.Parameters.AddWithValue("@Bill_to", _UpdateItem.Bill_to)
            updateCommand.Parameters.AddWithValue("@Contact", _UpdateItem.Contact)
            updateCommand.Parameters.AddWithValue("@Company", _UpdateItem.Company)
            updateCommand.Parameters.AddWithValue("@First_Name", _UpdateItem.First_Name)
            updateCommand.Parameters.AddWithValue("@M_I", _UpdateItem.M_I)
            updateCommand.Parameters.AddWithValue("@Last_Name", _UpdateItem.Last_Name)
            updateCommand.Parameters.AddWithValue("@Phone", _UpdateItem.Phone)
            updateCommand.Parameters.AddWithValue("@Alt_Phone", _UpdateItem.Alt_Phone)
            updateCommand.Parameters.AddWithValue("@Fax", _UpdateItem.Fax)



            'updateCommand.CommandText = "INSERT INTO EXCEL (id,Customer,Bill_to,Contact,Company,First_Name,M_I,Last_Name,Phone,Alt_Phone,Fax) VALUES ('" & _UpdateItem.id & "','" & _UpdateItem.Customer & "','" & _UpdateItem.Bill_to & "','" & _UpdateItem.Contact & "','" & _UpdateItem.Company & "','" & _UpdateItem.First_Name & "','" & _UpdateItem.M_I & "','" & _UpdateItem.Last_Name & "','" & _UpdateItem.Phone & "','" & _UpdateItem.Alt_Phone & "','" & _UpdateItem.Fax & "') ON DUPLICATE KEY UPDATE Customer= '" & _UpdateItem.Customer & "' Bill_to= '" & _UpdateItem.Bill_to & "' Contact= '" & _UpdateItem.Contact & "' Company= '" & _UpdateItem.Company & "' First_Name= '" & _UpdateItem.First_Name & "' M_I= '" & _UpdateItem.M_I & "' Last_Name= '" & _UpdateItem.Last_Name & "' Phone= '" & _UpdateItem.Phone & "' Alt_Phone= '" & _UpdateItem.Alt_Phone & "' Fax= '" & _UpdateItem.Fax & "'"
            'updateCommand.CommandText = "INSERT INTO quickbooks_imports (Customer,Bill_to,Contact,Company,First_Name,M_I,Last_Name,Phone,Alt_Phone,Fax) VALUES ('" & _UpdateItem.Customer & "','" & _UpdateItem.Bill_to & "','" & _UpdateItem.Contact & "','" & _UpdateItem.Company & "','" & _UpdateItem.First_Name & "','" & _UpdateItem.M_I & "','" & _UpdateItem.Last_Name & "','" & _UpdateItem.Phone & "','" & _UpdateItem.Alt_Phone & "','" & _UpdateItem.Fax & "') "
            _dbconn.Open()
            updateCommand.ExecuteNonQuery()

            _db.SaveChanges()

and I am still getting the fatal exception on the updateCommand.ExecuteNonQuery()

Fatal error encountered during command execution.

InnerException Message: “Parameter ‘?’ must be defined.”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:03:15+00:00Added an answer on May 25, 2026 at 8:03 pm

    You need to use parameters which will properly escape your strings for database execution.

    Refer to this link. http://www.devart.com/dotconnect/mysql/docs/Parameters.html

    Edit: Try using named parameters instead:

    updateCommand.CommandText = "INSERT INTO quickbooks_imports (Customer,Bill_to,Contact,Company,First_Name,M_I,Last_Name,Phone,Alt_Phone,Fax) VALUES ("@Customer", "@Bill_to", "@Contact", "@Company", "@First_Name", "@M_I", "@Last_Name", "@Phone", "@Alt_Phone", "@Fax")"
    updateCommand.Parameters.AddWithValue("@Customer", _UpdateItem.Customer)
    updateCommand.Parameters.AddWithValue("@Bill_to", _UpdateItem.Bill_to)
    updateCommand.Parameters.AddWithValue("@Contact", _UpdateItem.Contact)
    updateCommand.Parameters.AddWithValue("@Company", _UpdateItem.Company)
    updateCommand.Parameters.AddWithValue("@First_Name", _UpdateItem.First_Name)
    updateCommand.Parameters.AddWithValue("@M_I", _UpdateItem.M_I)
    updateCommand.Parameters.AddWithValue("@Last_Name", _UpdateItem.Last_Name)
    updateCommand.Parameters.AddWithValue("@Phone", _UpdateItem.Phone)
    updateCommand.Parameters.AddWithValue("@Alt_Phone", _UpdateItem.Alt_Phone)
    updateCommand.Parameters.AddWithValue("@Fax", _UpdateItem.Fax)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For part of a web application the user needs to import some data from
I'm working on an application that needs to accept posted data from a form
If you have a Windows application that needs to write working files as part
Am working on an application that needs to count words from documents and revisions.
A part of the application that I am working on is a legacy Vb6
A part of the application I'm working on is an swf that shows a
I'm working on an application in Java, that needs to do some complex logic
I am currently working on a VB.NET desktop application that uses .mdb (Access) database
I'm working on a MacRuby application that needs to make updates to config files
I'm writing a Java application that needs a lot of static data that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.