By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

MySQL Insert Error

P: n/a
I am trying to INSERT record in MYSQL database, but each time the code tries
to execute the command: MySQL_cmdGLAccount.ExecuteNonQuery(), it reports an
error with the message
"COLUMN COUNT DOESN'T MATCH VALUE COUNT AT ROW 1"
Am using MYSQL CONNECTOR FOR NET VERY 1.0.3 as my provider. Am wondering
what is going on in my code. Below is part of the code.

MySQL_Cnn.Open()
myTrans = MySQL_Cnn.BeginTransaction
MySQL_cmdGLAccount.Transaction = myTrans

strSQLInsert = "INSERT INTO
GLAccount(AccountNo,AccountName,AccountType,Note,S uspend,RetainedEarnings,DateTime) " _
& " VALUES (intAcctNo,'" & txtAccountName.Text & "','" &
strAccountType & "','" & txtNote.Text & "' " _
& " '" & strSuspend & "','" & strRetainedEarnings &
"',NOWDATE)"
MySQL_cmdGLAccount.CommandText = strSQLInsert
MySQL_cmdGLAccount.Connection = MySQL_Cnn
MySQL_cmdGLAccount.ExecuteNonQuery()
myTrans.Commit()
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Do a debug or msgbox of the SQL string before executing it. I suspect a
comma is misplaced somewhere.

"INSERT ERROR" wrote:
I am trying to INSERT record in MYSQL database, but each time the code tries
to execute the command: MySQL_cmdGLAccount.ExecuteNonQuery(), it reports an
error with the message
"COLUMN COUNT DOESN'T MATCH VALUE COUNT AT ROW 1"
Am using MYSQL CONNECTOR FOR NET VERY 1.0.3 as my provider. Am wondering
what is going on in my code. Below is part of the code.

MySQL_Cnn.Open()
myTrans = MySQL_Cnn.BeginTransaction
MySQL_cmdGLAccount.Transaction = myTrans

strSQLInsert = "INSERT INTO
GLAccount(AccountNo,AccountName,AccountType,Note,S uspend,RetainedEarnings,DateTime) " _
& " VALUES (intAcctNo,'" & txtAccountName.Text & "','" &
strAccountType & "','" & txtNote.Text & "' " _
& " '" & strSuspend & "','" & strRetainedEarnings &
"',NOWDATE)"
MySQL_cmdGLAccount.CommandText = strSQLInsert
MySQL_cmdGLAccount.Connection = MySQL_Cnn
MySQL_cmdGLAccount.ExecuteNonQuery()
myTrans.Commit()

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.