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

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+
3 Replies


P: n/a
Here is the problem

You only have 6 values and 7 parameters. You are missing a comma.



"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

P: n/a
instead of concatinating values like that you should really used paramater
fields.

"INSERT ERROR" <IN*********@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
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 #3

P: n/a
Missing a comma right here:

& txtNote.Text & "' " _
& " '" & strSuspend

"INSERT ERROR" <IN*********@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...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 #4

This discussion thread is closed

Replies have been disabled for this discussion.