Showing posts with label attempt. Show all posts
Showing posts with label attempt. Show all posts

Thursday, March 22, 2012

adventureworks attach error

i've attempt to atach the adventureWorks database to follow the webcourse 2924 but I got the following error:

TITLE: Microsoft SQL Server Management Studio

Attach database failed for Server 'localhost'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Could not find row in sysindexes for database ID 28, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database 'AdventureWorks'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)

But, how can I run DBCC CHECKTABLE on non attached database?

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=602&LinkId=20476


BUTTONS:

OK

Mary,

Please follow this article to attach AW.

http://msdn2.microsoft.com/en-us/library/ms310325.aspx

Sunday, February 19, 2012

ADO Recordsets 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.#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!!!