8/24/2025 6:38:02 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
|
|
|
|
Weird ADO error...
Posted: 25 Jun 08 11:47 AM
|
Referring to the code below, when I run it and take out the stop statement (or just say no to the debugger prompt), the message box shows the count to be 3 and the error message alerted is an empty string
When I put in the stop statement (or just say yes to the debugger) and step through, the parameter count is 6 and I receive the error message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."
Anyone know why this is? I assume it has to do with timing, but it's just weird.
Jeff
On Error Resume Next sql = "UPDATE Table1 SET field1 = ?, field2 = ? WHERE prkey = ?" Dim oSlxDB Set oSlxDb = New SLX_DB Dim cmd Set cmd = CreateObject("ADODB.Command") cmd.ActiveConnection = oSlxDb.Connection Stop With cmd .CommandType = adCmdText .Prepared = True .CommandText = sql .Parameters.Append .CreateParameter("field1", adNumeric, adParamInput, , value1) .Parameters.Append .CreateParameter("field2", adDBDate, adParamInput, , value2) .Parameters.Append .CreateParameter("field3", adVarChar, adParamInput, 12, value3) MsgBox "count: " & cmd.Parameters.Count .Execute End With MsgBox "description: " & Err.Description
|
|
|
|
Re: Weird ADO error...
Posted: 25 Jun 08 12:47 PM
|
Jeff,
If you access the parameters collection via the debugger, it auto loads the parameters for you. Thus, when you append 3 more params you have 6. You can just get rid of your appends and set the values as such: .Parameters(0).Value = value1 etc
HTH!
Timmus |
|
|
|
Re: Weird ADO error...
Posted: 25 Jun 08 3:23 PM
|
I actually had done that, but couldn't figure out why every example I've seen had the appends statement. Being a little obsessive about these things, I couldn't let it go. What I didn't realize is that the debugger auto-loads the parameters for you. That seems a bit odd; I would expect the debugger to show you what it has, but not add them for you. That certainly explains the issue, though.
Thanks, and it did help!
Jeff
|
|
|
|
Re: Weird ADO error...
Posted: 25 Jun 08 3:26 PM
|
Happy to help, Jeff. I do want to clarify that I did not mean the debugger autoloads the params. Accessing the parameters collection triggers ADO to load the params if the collection is empty. If you would have accessed the collection in your code before your breakpoint you would have seen the 3 params would have already been there.
BTW I typically add params explicitly in my code as well.
Timmus |
|
|
|
Re: Weird ADO error...
Posted: 25 Jun 08 3:35 PM
|
Got - that makes more sense than the debugger auto-populating them.
Call me crazy, but I don't like the idea that accessing it auto-populates them. I personally think it should throw an exception if I attempt to access a non-existent collection. Oh, well, at least I know what's causing what I was seeing.
Thx again!
Jeff
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|