Click to See Complete Forum and Search --> : Using Execute w/VB6 & SQL 7


October 4th, 1999, 05:31 PM
I am converting a program from VB3 to VB6. In the original code, Set AppSN1 = AppDB.CreateSnapshot(SQLStmt$, DB_SQLPASSTHROUGH)where SQLStmt$ = 'delFileCond 'L'{CRLF}go{CRLF}insFileCond 'L', 'Reissue fee due', it works fine. In VB6, where I use cnConnect.Execute SQLStmt$, dbFailOnError, it fails. I ran SQL Trace and find that in VB6 not only do I get the two stored procedures that I am expecting, I also get, after the stored procedures have run, this SQL: select * from delFileCond 'L'{CRLF}go{CRLF}insFileCond 'L', 'Reissue fee due'. "select * from" is appended to the front of the SQL I sent and submitted again, for some reason. It appears to be the contents of a cache and it's reproducable. The same additional SQL attempts to execute every time I try. I'm not sending the additional statements.
Can anyone suggest a place to look here? Is it the way I'm doing the execute?

czimmerman
October 4th, 1999, 06:04 PM
I'm sorry this won't exactly answer your question but....

I'd first recommend getting rid of the CreateSnapshot statement, changing it to OpenRecordset, with the second argument set to dbOpenSnapshot. The CreateSnapshot is only there for backwards compatibility and if you have problems with it, you are pretty much on your own.

If you want to do a little more work, I'd suggest converting to ADO. If you do this right, I can guarantee you (well 99% guarantee anyway) that you won't have problems with SQL Server and stored procedures, since I use the two together on a regular basis with no weird stuff. ADO is being forced upon us by Microsoft for better or worse (better in most cases but not all IMHO), and DAO is not really the right technology for SQL Server anyway.

October 5th, 1999, 09:55 AM
The CreateSnapShot was my VB3 code and is working fine. My problem is with the Connection.Execute code. When I submit it, SQL runs it OK but then appends "Select * from" to the front of it and attempts to run it again. This fails, causing the transaction to fail. I don't know where the select is coming from, I can see my SQL statement as it is being sent. My only guess is that there is a cache somewhere that is being tacked onto the end of my statement. However, it's always the same: no matter how many times I've run it, the appended text remains constant. Any clues?