Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: 80040e10 "COUNT field incorrect"


Message #1 by mthomason@h... on Wed, 17 Oct 2001 21:12:56
Greetings.  One of my users gets the following error message from an asp 

page attempting to execute an insert statement(sql 7.0):



Error Type:

Microsoft OLE DB Provider for ODBC Drivers(0x80040e10)

[Microsoft][ODBC SQL Server Driver] COUNT field incorrect



The insert statement:



SQL = "INSERT hpbnet..DIM_Survey_Questions (Entry_Time, Entered_By, 

QuestionTitle, Question) VALUES ('" & txtTime & "', '" & txtShortUser 

& "', '" & txtQuestionTitle & "', '" & txtQuestion & "')"

Set RS1 = MyConn.Execute(SQL)



It seems this error can be produced by using illegal characters as field 

names ('?', etc.)  I don't believe I am doing this!



Any thoughts?



Thanks!!





Message #2 by "O'Neil Brown" <oneil_brown@h...> on Wed, 17 Oct 2001 20:56:35 -0400
I am not an expert but there are two periods after "hpbnet" is that how it

should be

Message #3 by David Cameron <dcameron@i...> on Thu, 18 Oct 2001 13:53:41 +1000
use Response.Write to dump your code to the screen. Check your generated SQL

string.



regards

David Cameron

nOw.b2b

dcameron@i...



Message #4 by "Jimmy Ho" <jimmyyl@h...> on Thu, 18 Oct 2001 18:42:37 +0800
For the insert table statement, there should be a quote for parameters.

e.g insert into table(para1, para2) VALUES ('name1' , 'name2')

So for your case, it should be

SQLstatement = "insert into table(para1, para2) VALUES (" & "'" & txtName1 &

"'," & "'" & txtName2 & "')"

Note the "'" tricks since the ' is part of the string.

By the way, it is a good practice to break this SQL string into parts like:

SQLstr = "insert into table(para1, para2) VALUES ("

SQLstr = SQLstr &  "'" & txtName1 & "'," & "'" & txtName2 & "')"

It will be easier for troubleshooting.

Hope this help.

Thanx



Message #5 by David Cameron <dcameron@i...> on Fri, 19 Oct 2001 10:17:24 +1000
>> For the insert table statement, there should be a quote for parameters.



Correction, for string columns use quotes. For numbers you should *not* use

quotes. For dates use the appropriate date delimiter for you DBMS (# for

access, ' for SQL Server etc). Also if you are passing though string values

you might want to replace all single quotes in the string with 2 single

quotes (Replace(MyVar, "'", "''")) to avoid getting errors.



regards

David Cameron

nOw.b2b

dcameron@i...

  Return to Index