|
-
December 11th, 2004, 08:16 PM
#1
a puzzle about DB in the vc
hi guys,i am doing a db recently ,but i have met a little problem .at first let me tell u something about the background that i have set for the DB :my developer tool is visual c++ 6.0,my data source tool is MS Access .see that there are many tables in the database ,such as a table for loginning ,tables for searching ,tables for initializing ,and so on .oh sorry i forget one thing i use the ODBC to connect the data source with vc application .
and the problem is that i can not login every time when i log in it comes the error not allowing me in
after i checking that my database is connected to the application .it made some changes .it asked me to choose a data source ,there are two kinds of data source in the given choose range ,such as file data source ,and machine data source ,and so on .i tried the two ,but both failed , the error information is that ""the data source file can not be opened!"i am so puzzled .because i had already connecteed it with a ODBC i am wondering why this comes the error ,
because of the vast source code ,i am not to give the exact source code
so please forgive me .and i hope that one of u who is kind enough can help me
jolley
Regards,
-
December 11th, 2004, 08:38 PM
#2
Re: a puzzle about DB in the vc
in order to make things clearer .i give a part of code (the codes functions as to connect the data base and execute the SQL statement ):
Code:
try
{
CDatabase cdb;
CRecordset recset(&cdb);
cdb.open();
CString strQuery="select * from Customer";
recset.open(CRecordset::forwordOnly,strQuery);
cdb.close()
}
catch(CDBException& e)
{
CString errorMessage;
errorMessage.Format("ODBC=%d%s",e.m_strerror/*sorry there maybe a mistake*/) ;
AfxMessageBox("the data file can not be executed because of this error");
}
BUT at first used this way of executing SQL statement .i am content with the following
Code:
CDatabase cdb;
CString strQuery="select * from Customer";
cdb.ExecuteSQL(strQuery);
I get something from people telling that using ExecuteSQL will damage the ODBC non-dependence ,so i choose the first version and i am also contented that i have added exceptions to the database.
however ,what i have done doesnot change the fate----no result and it doesnot allow my loggining ,and now i try .....
yeah i hope that i can get some helps from u ,ok?
much appreciation !
jolley
Regards.
-
December 12th, 2004, 08:01 AM
#3
Re: a puzzle about DB in the vc
it would be easier for you if you use ADO connection...
you map your db thru DSN or DSNless connectivity...
-
December 12th, 2004, 07:55 PM
#4
Re: a puzzle about DB in the vc
thanks DjChris14, u didnot answer my question exactly but i want to learn something about the ODBC ,atcually i know that ADO is more effective than ODBC ,however ,i just want to get new viewpoint about ODBC ,anyway ,the ODBC is a way of expressing database .
i will be glad if u can solve my problem .for i have doubted the feasiblity of the ODBC ,besides ,my programme is on my way now ,so i will be sorry if i stop the programme and choose another ADO way !
i do hope that u can help me ,that is no way to talk which way can express the database better but how to implement it in the ODBC way ,and i will turn it to my prof.a few days later ,so time is used up!
jolley
Regards,
-
December 12th, 2004, 10:43 PM
#5
Re: a puzzle about DB in the vc
the problem is that i can not login every time when i log in it comes the error not allowing me in after i checking that my database is connected to the application ..it made some changes .it asked me to choose a data source ,there are two kinds of data source in the given choose range ,such as file data source ,and machine data source ,and so on .i tried the two ,but both failed , the error information is that ""the data source file can not be opened!"i am so puzzled .
By "it" I presume you are referring to the AppWizard. At what stage do you get all these things ?
-
December 13th, 2004, 08:00 AM
#6
Re: a puzzle about DB in the vc
What EXACTLY does the error message say that it gives you? Also, there's no reason to supply the database with a select statement. Your CRecordset class will generate its own in the Open call.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|