Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASP and SQL Insert Statement Problems
Message
 
To
15/11/2000 10:59:05
General information
Forum:
Internet
Category:
Active Server Page
Miscellaneous
Thread ID:
00442115
Message ID:
00442201
Views:
8
>I am using the command object to modify and add records to SQL 6.5 tables on our web site. An excerpt of the code used is below. Problem: this code works for the edit but NOT for the add. To complicate matters, I use the same code in another asp page, and it works great for both ADD and Edit. Can any one see what might be the problem????
>
> ' code excerpt - first 3 lines used for both edit or add
> ' our connection, oconn, is set up in an include file
> SET objcmd = Server.CreateObject("ADODB.Command")
> objcmd.ActiveConnection = oConn
> objcmd.CommandType = adcmdText
> ' if this is an edit, I build an UPDATE string
> ' if it is an add, I build the string below
> uniq = "_"&cstr(datevalue(now())&hour(now())&minute(now())&second(now()))
> updatestr = "insert into corecomponent *** this line does NOT break like this in the program <g> *****(component_name,component_description,component_class,create_date,create_userid,uniqueness_column,manager_type,component_status) values ("
> updatestr = updatestr & "'"& cstr(Request.Form("textname"))&"'"
> updatestr = updatestr & ",'" &cstr(trim(Request.Form("textdesc")))&"'"
> updatestr = updatestr & "," &cstr(Request.Form("theclass"))
> updatestr = updatestr & ",'"& now()
> updatestr = updatestr & "','"&cstr(Request.Form("txtcreatedby"))&"'"
> updatestr = updatestr & ",'"&uniq&"',0,"
> updatestr = updatestr & cstr(Request.Form("txtstatus"))&")"
> ' both edit and add use the lines below
> objcmd.CommandText = updatestr
> objcmd.Execute
>
>This is driving me crazy! TIA, TIA, TIA for any insight.

Don't you need a set on this line:
objcmd.ActiveConnection = oConn

Like:
Set objcmd.ActiveConnection = oConn

Also, can you paste the value of UpdateStr here?
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform