473,651 Members | 3,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem With Insert into MySQL DB using VB.Net 2005

Hello everyone,
I am having a issue inserting values into a MYSQL table, and for the life of
me, I can figure out why. I know the connection is successful, however I am
getting errors.

The table has 4 fields, all of them are Text values.

Here is my code:

Dim myCommand As New MySqlCommand
myCommand.Conne ction = conn
myCommand.Comma ndText = "INSERT INTO Order(ONUM, Password, Email, Process) "
_
& "Values (" _
& "'" & txtOrder.Text & "', " _
& "'" & txtPassword.Tex t & "', " _
& "'" & txtEmail.Text & "', " _
& "'" & comStatus.Selec tedItem & "')"

Try
conn.Open()
myCommand.Execu teNonQuery()
Catch myerror As MySqlException
MsgBox("There was an error updating the database: " & myerror.Message )
End Try

And the error i recieve from it is as follows:
#42000You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'Order(ONUM, Password, Email, Process) Values ('353643', '353623542',
'test@here.' at line 1

I have also noticed that some of the data I enter on my form is shortened.
i.e the email address I actually entered on the form was te**@here.com
however the error message only displays test@here.
Could anyone help me with my issue?
Regards
Jan 10 '06 #1
3 2171
I think your problem is that the combobox.select editem property is an
object, and you will either need to apply the .Text method or assign it
to an onject and use the .ToString method.

Jan 10 '06 #2
Hi,

Like Zack said you should try comStatus.Selec tedItem.ToStrin g or
comStatus.Text in your insert command. A good place for questions about the
mysql dot net connector is here.

http://forums.mysql.com/list.php?38

Ken
-------------------
"Materialis ed" <ma**********@p rivacy.net> wrote in message
news:42******** *****@individua l.net...
Hello everyone,
I am having a issue inserting values into a MYSQL table, and for the life
of me, I can figure out why. I know the connection is successful, however
I am getting errors.

The table has 4 fields, all of them are Text values.

Here is my code:

Dim myCommand As New MySqlCommand
myCommand.Conne ction = conn
myCommand.Comma ndText = "INSERT INTO Order(ONUM, Password, Email, Process)
" _
& "Values (" _
& "'" & txtOrder.Text & "', " _
& "'" & txtPassword.Tex t & "', " _
& "'" & txtEmail.Text & "', " _
& "'" & comStatus.Selec tedItem & "')"

Try
conn.Open()
myCommand.Execu teNonQuery()
Catch myerror As MySqlException
MsgBox("There was an error updating the database: " & myerror.Message )
End Try

And the error i recieve from it is as follows:
#42000You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'Order(ONUM, Password, Email, Process) Values ('353643', '353623542',
'test@here.' at line 1

I have also noticed that some of the data I enter on my form is shortened.
i.e the email address I actually entered on the form was te**@here.com
however the error message only displays test@here.
Could anyone help me with my issue?
Regards

Jan 10 '06 #3
Materialised wrote:
Hello everyone,
I am having a issue inserting values into a MYSQL table, and for the life of
me, I can figure out why. I know the connection is successful, however I am
getting errors.

The table has 4 fields, all of them are Text values.

Here is my code:

Dim myCommand As New MySqlCommand
myCommand.Conne ction = conn
myCommand.Comma ndText = "INSERT INTO Order(ONUM, Password, Email, Process) "


Order is a reserved word. You will find you cannot even execute 'SELECT
* FROM Order'. You need to put backticks around `Order`, or chose a
more suitable table name.

--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
Jan 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5042
by: sinasalek | last post by:
i have a problem with MySQL 4.1.x and UTF8. in version 4.0, i'm using html forms with utf8 charset for inserting unicode strings. but in version 4.1.x it is not working! if i change the charset of column, ALTER TABLE `icons` CHANGE `name_farsi` `name_farsi` VARCHAR( 99 ) CHARACTER SET utf8 COLLATE utf8_persian_ci DEFAULT NULL and change default charset of database like below code :
2
2415
by: Bob Bedford | last post by:
I've a query with insert records in a table. I've 2 fields: DateTimeInsertion and DateTimeLastModification. When I create the record, I must have those 2 fields set the same value. Now I've this Insert into article values(now(), now(),....)
4
1807
by: Caversham | last post by:
I am trying to insert data into the fields id and term of the table key. id is an auto-incrementing field. Each of the following forms fails:- INSERT INTO key (id, term) VALUES (0, 'dog') INSERT INTO key ('id', 'term') VALUES (0, 'dog') INSERT INTO 'key' ('id', 'term') VALUES (0, 'dog')
11
7155
by: grumfish | last post by:
I'm trying to add a row to a MySQL table using insert. Here is the code: connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", db="japanese") cursor = connection.cursor() cursor.execute("INSERT INTO edict (kanji, kana, meaning) VALUES (%s, %s, %s)", ("a", "b", "c") ) connection.close() After running, a SELECT * on the table shows no new rows added. Adding
5
1547
by: Lad | last post by:
I have the following program( only insert a record) ################ import MySQLdb conn = MySQLdb.connect (host = "localhost",user = "", passwd = "",db="dilynamobily") cursor = conn.cursor () cursor.execute("""CREATE TABLE produkt1 ( id int(10) unsigned NOT NULL auto_increment, MyNumber varchar(30) NOT NULL default '',
6
4560
by: Murtix Van Basten | last post by:
HI all, I am trying to migrate a database from mysql to mssql2k. I use myODBC to connect to mysql server to pull the database from DTS and insert in to sql server. But in mysql server, there is one huge table. Size of it is 1.3 GB and more than 12 million rows. While I try with DTS, it transfers all tables in the database except this huge table. First I thought it would be the resources of the computer not enough (512MB physical ram...
0
2483
by: Rajesh Kapur | last post by:
I have a master slave configuration on linux machines running MySQL 4.0.21. Once every hour, a process deletes about 9000 rows and re-inserts fresh data on the master. The master process completes processing under a minute. The updates arrive on the slave within seconds. However, the slave takes about 15-20 minutes to post the same updates. Both master and slave have InnoDB tables. The master and the slave are almost identical in capacity...
31
4578
by: Extremest | last post by:
I have a loop that is set to run as long as the arraylist is > 0. at the beginning of this loop I grab the first object and then remove it. I then go into another loop that checks to see if there are more objects that match the first object that i grabbed. If they match then I put them in an array. I would like to remove each match from the arraylist as I find them to speed things up and so that they don't get checked again. If I try...
3
28080
Atli
by: Atli | last post by:
Hi. I've been trying to insert multiple rows into a table using a single INSERT statement in MSSQL / SQL Server 2005. I could of course cheat and have my C# code insert each row using some sort of a loop, but where is the fun in that :-) If you'r familliar with MySQL, this MySQL query would do what I am trying to do with MSSQL / SQL Server 2005. INSERT INTO UserInfo(InfoName, InfoValue) VALUES
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.