468,134 Members | 1,231 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,134 developers. It's quick & easy.

ADO Recordset's object method Open

Hello group!

I use MS Visual C++ 6.0, ADO, MS SQL Server 2000.
When I attempt to open my database I meet with a following problem:
when I try to get a bookmark of the current record in a Recordset
object a following run-time error occurs: Unhandled exception in
testdb.exe(KERNEL32.DLL):
0xE06D7363: Microsoft C++ Exception.

I created my database by 3 SQL commands:

create database testdb
create table testtable
(
i int
)
insert into testtable values(0)

The error occurs in the following code snippet:
#import "D:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
int main()
{
CoInitialize(NULL);

bstr_t strCnn("Provider=sqloledb;Data Source=;"
"Initial Catalog=testdb;Trusted_Connection=YES;");

const char* tablename = "testtable";

_RecordsetPtr recs;
recs.CreateInstance(__uuidof(Recordset) );
recs -> Open(tablename, strCnn, adOpenStatic,
adLockOptimistic,adCmdTable);
_variant_t bm = recs -> Bookmark; // the error occurs here
recs -> Close();
CoUninitialize();
}

During the debugging this code I met that the error depended on a type
of locking. When I set adLockBatchOptimistic or adLockOptimistic
or adLockPessimistic the error occurs but when I set adLockReadOnly or
adLockUnspecified it doesn't occur. By the way this error doesn't
occur when
I open Pubs database with any type of locking. What is a cause of this
error?
Thank you.
Jul 20 '05 #1
1 5540
#import "D:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
int main()
{
CoInitialize(NULL);

bstr_t strCnn("Provider=sqloledb;Data Source=;"
"Initial Catalog=testdb;Trusted_Connection=YES;");

const char* tablename = "testtable";

_RecordsetPtr recs;
recs.CreateInstance(__uuidof(Recordset) );
recs -> Open(tablename, strCnn, adOpenStatic,
adLockOptimistic,adCmdTable);
bool r = recs -> Supports(adBookmark);
_variant_t bm = recs -> Bookmark; // the error occurs here
recs -> Close();
CoUninitialize();
}
If I opened testdb then recs -> Supports(adBookmark)
returned true when I used adLockReadOnly or adLockUnspecified. If I
used other
LockTypes then this function returned false and the error occured in
this line:
__variant_t bm = recs -> Bookmark; // the error occurs here

If I opened the Pubs database then recs -> Supports(adBookmark)
returned true for any LockType. Why does a Recordset object support
bookmark functionality for any LockType if I open the Pubs database?!
I can't understand it!!!
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Thomas Scheiderich | last post: by
22 posts views Thread by Gerry Abbott | last post: by
2 posts views Thread by corepaul | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.