Click here to Skip to main content
13,001,686 members (64,991 online)
Rate this:
Please Sign up or sign in to vote.
See more:
whenever i use a word with apostrophe like it's , it generate's " a error in mysql command check your manual ".
because as we use '"& texbox.text &"' in mysql commmand . so as we type something like this it input as 'its's' and generate error , so any solution . Waiting ........

for Better Understanding.

Dim cn As New MySqlConnection
    Dim cd As MySqlCommand
    Dim s As String
cn.ConnectionString = "server=localhost; user id=root; password=; database=dc"
s = " insert into table_name(column1,column2,..column_n) values('"& textbox1.text&"')"
            cd = New MySqlCommand(s, cn)
Posted 17-Jan-13 0:20am
Updated 17-Jan-13 19:06pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Can you provide a code that causes this error. You have mentioned using tag that 4 is used. It is really hard to achieve such behavior using framework.

Generally speaking, it is recommended to use prepared statements to execute the query.
For example, if SQLCommand is used - the code could be

command->CommandText = S"insert into Region (RegionID, RegionDescription) values (@id, @desc)" ;
command->Parameters->Add (S"@id", __box(id));
command->Parameters->Add (S"@desc", desc);
command->Prepare();  // Calling Prepare after having set the CommandText and parameters.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100