CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 SQL INSERT Command returns error.[RESOLVED]

Print topic Send  topic

Author Message
kevind

Posts: 251
Posted: 05/27/2008, 12:28 PM

Hi, I'm using ASP Code to push some SQL commands against an MS Access DB.

Here's the code (assume all variables are DIM'd)
  
	Set conn = new clsDBConnection1  
	conn.open  
  
SQL="INSERT INTO Payments ([Date],No,InvestigatorID,Created,CUser) VALUES (" + _   
						conn.ToSQL(CCGetParam("crit_PayDate",empty),ccsDate) +","+ _   
						cStr(HiPayNum) +", "+ _   
						conn.ToSQL(rsInvestigators.Fields("ID"),ccsText) + "," + _   
						conn.ToSQL(now(),ccsDate) + "," + _   
						conn.ToSQL(CCGetUserLogin(),ccsText) +");"  
  
	'try inserting - on error abort pays  
	Set rsInsertPayNo = conn.Execute(SQL)  

the SQL string results as this:

INSERT INTO Payments ([Date],No,InvestigatorID,Created,CUser) VALUES (#27-May-2008#,2, '{07872F33-3593-4AE8-BD91-E160366D9557}',#05/27/2008 15:25:39#,'dba');

conn.Errors.ToString comes back Syntax error in INSERT INTO statement. (Microsoft JET Database Engine)

I can run the SQL statement in Query Designer inside MS Sql without error.

I have tried dropping the date column and reformatting that first date value without any change in results.

Any Ideas anyone?

thanks,
kd
_________________
thanks
Kevin

======================
CCS 3.2.x / ASP / MS Access /mySQL / PHP / jQuery / jQuery UI / jQuery Mobile
View profile  Send private message
mljonzs

Posts: 124
Posted: 05/27/2008, 12:46 PM

Try putting single quotes into the Values clause around the cStr(HiPayNum) statement since you aren't using the ToSQL for this parameter.....


So code should be
...ccsDate) + ",'"+ cStr(HiPayNum)+"', "....

_________________
What does not begin WITH God, will end in failure!
View profile  Send private message
kevind

Posts: 251
Posted: 05/27/2008, 12:49 PM

duh, needed [square] brackets around all field names (not just date which i thought might be reserved) to make it happy :-D
_________________
thanks
Kevin

======================
CCS 3.2.x / ASP / MS Access /mySQL / PHP / jQuery / jQuery UI / jQuery Mobile
View profile  Send private message
mljonzs

Posts: 124
Posted: 05/27/2008, 12:52 PM

That makes sense - Access is a bit goofy that way. :) Sorry, I didn't think about that one! :)

Glad you got it though! :)
_________________
What does not begin WITH God, will end in failure!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.