Probleme de driver ODBC in MS. Access Driver

Acest forum este dedicat intrebarilor de Windows API, folosing C/C++
Post Reply
User avatar
Silviu Ardelean
Senior
Senior
Posts: 1175
Joined: 12 Jul 2007, 09:22
Judet: Timiş
Location: Timisoara
Contact:

Probleme de driver ODBC in MS. Access Driver

Post by Silviu Ardelean » 15 Dec 2010, 10:09

Am niste probleme cu executia unei iterogari banale intr-o baza de date MS Access. Pe masina mea am instalat Access 2007 iar formatul bazei de date e Access 2002-2003 compatible mode.
Stringul de conexiune la baza de date este: Driver={Microsoft Access Driver (*.mdb)}; DBQ=D:\\myAppPath\\myDatabase.mdb.

Ma conectez la baza de date cu succes folosind SQLDriverConnect() - rezultatul intors de aceasta functie e 0.

Code: Select all

		nRetCode = SQLDriverConnect(m_hDBC, NULL, (SQLTCHAR *) m_szFullDSN.c_str(), (SQLSMALLINT) m_szFullDSN.length(), 
					(SQLTCHAR *) szFullDSN, (SQLSMALLINT)sizeof(szFullDSN)/sizeof(szFullDSN[0]), &nLen, SQL_DRIVER_NOPROMPT);
Cand sa execut o banala interogare ( "SELECT * FROM myTable" ) folosesc SQLExecDirect()

Code: Select all

nRetCode = SQLExecDirect(m_hSTM, (SQLTCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
Si stupize stupize, nRetCode = -1.

Rezultatul erorii il aflu cu HandleError()

Code: Select all

	TCHAR *szErr = HandleError(m_hSTM, SQL_HANDLE_STMT, nRetCode);
	sErrorMsg = szErr ? szErr : _T("");
si este: [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented
Asta in conditiile in care daca-mi deschid baza de date in Access 2007 am: Security Warning Certain content in the database has been disabled. Am incercat si cu acest content enable dar degeaba...
Mai mult ca sigur nu e o problema de programare ci mai mult de configurare.
V-ati lovit de aceasta problema? Daca da, care e rezolvarea?



User avatar
Silviu Ardelean
Senior
Senior
Posts: 1175
Joined: 12 Jul 2007, 09:22
Judet: Timiş
Location: Timisoara
Contact:

Re: Probleme de driver ODBC in MS. Access Driver

Post by Silviu Ardelean » 15 Dec 2010, 11:32

Mi-am rezolvat problema cu interogarea ( de fapt, am evitat-o :) ) exportand datele in MS SQL Server si schimband stringul de conexiune.

Raman deschis la idei legate de problema ce a aparut in legatura cu MS Access 2007. Multumesc!

User avatar
Andreas
Membru
Membru
Posts: 117
Joined: 09 Nov 2008, 12:13
Judet: Timiş
Location: Timisoara

Re: Probleme de driver ODBC in MS. Access Driver

Post by Andreas » 15 Dec 2010, 15:49

problema din:

Code: Select all

nRetCode = SQLExecDirect(m_hSTM, (SQLTCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
este tipul lui szQuery care este WCHAR*, cred...probabil driver-ul de MS Access "nu stie d'astea"; fara Unicode functia returneaza 0

User avatar
Silviu Ardelean
Senior
Senior
Posts: 1175
Joined: 12 Jul 2007, 09:22
Judet: Timiş
Location: Timisoara
Contact:

Re: Probleme de driver ODBC in MS. Access Driver

Post by Silviu Ardelean » 15 Dec 2010, 16:04

Andreas wrote:problema din:

Code: Select all

nRetCode = SQLExecDirect(m_hSTM, (SQLTCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
este tipul lui szQuery care este WCHAR*, cred...probabil driver-ul de MS Access "nu stie d'astea"; fara Unicode functia returneaza 0
Sincer,nu am incercat pe proiect non-unicode, dar daca asta e problema... atunci sa fie sanatosi. Oricum, aseara m-am chiorat ca prostu' vreo 5 minute sa aflu cum pot face o banala interogare in Access 2007 scriind cod sql (au ascuns bine functionalitatea, prin Ribbon). :ugeek:
Prefer Management Studio si MS SQL Server. :)

User avatar
cristianamarie
Membru++
Membru++
Posts: 480
Joined: 12 Mar 2009, 18:47
Judet: Iaşi
Location: Iasi

Re: Probleme de driver ODBC in MS. Access Driver

Post by cristianamarie » 15 Dec 2010, 17:06

Code: Select all

SQLExecDirect(m_hSTM, (SQLTCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
szQuery presupun ca e WCHAR. Sigur nu e vreun mismas de la setari?
Incearca un
SQLExecDirectW(m_hSTM, (SQLWCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
Nuclear launch detected

User avatar
Silviu Ardelean
Senior
Senior
Posts: 1175
Joined: 12 Jul 2007, 09:22
Judet: Timiş
Location: Timisoara
Contact:

Re: Probleme de driver ODBC in MS. Access Driver

Post by Silviu Ardelean » 15 Dec 2010, 18:12

cristianamarie wrote:

Code: Select all

SQLExecDirect(m_hSTM, (SQLTCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
szQuery presupun ca e WCHAR. Sigur nu e vreun mismas de la setari?
Incearca un
SQLExecDirectW(m_hSTM, (SQLWCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
Sigur nu asta e problema... din moment ce cu doar un alt string de conexiune specific MS SQL si iau datele din SQL Server fara probleme (cele exportate din Access). Proiectul e sigur, unicode (default).

Continui sa cred ca problema e la driver si mirifica setare din Access 2007 ce-o intalnesc la fiecare deschidere a bazei de date: Security Warning Certain content in the database has been disabled. De exemplu, trebuie s-o activez pentru a putea vedea relatiile dintre tabele un mod vizual.

neagu_laurentiu
Membru++
Membru++
Posts: 919
Joined: 23 Jul 2007, 11:32

Re: Probleme de driver ODBC in MS. Access Driver

Post by neagu_laurentiu » 15 Dec 2010, 18:34

Driverul folosit de tine nu are legatura cu 2007. Acesta din urma are alt format: http://www.connectionstrings.com/
Ai pus parametrii de securitate ? Din postul initial nu vad.

User avatar
cristianamarie
Membru++
Membru++
Posts: 480
Joined: 12 Mar 2009, 18:47
Judet: Iaşi
Location: Iasi

Re: Probleme de driver ODBC in MS. Access Driver

Post by cristianamarie » 15 Dec 2010, 21:22

Nu man, acu imi dau seama. E un first open, si trompeta de Access are nu stiu ce dialog cind deschizi "Certain database content has been disabled"
E asta de aici: http://www.blueclaw-db.com/access_2007/ ... arning.htm

Trebuie adaugata calea unde e fisierul fizic in Trusted Locations. Nu stiu cum se face asta din cod...
Nuclear launch detected

User avatar
cristianamarie
Membru++
Membru++
Posts: 480
Joined: 12 Mar 2009, 18:47
Judet: Iaşi
Location: Iasi

Re: Probleme de driver ODBC in MS. Access Driver

Post by cristianamarie » 15 Dec 2010, 21:27

Sorry, acu am vazut mesajul tau de mai sus. Da, aia e mirifica setare. Cred ca alta cale in afara de Trusted Locations nu e.
Links:
http://www.accessribbon.de/en/index.php ... _Locations
http://www.access-programmers.co.uk/for ... 36411.html

Tre' sa extragi probabil calea din path-ul spre .mdb, si sa pocnesti in registry new entry (faci un nou Location) si ar trebui sa fie ok.
(Nu lua de bun ce zic ca n-am incercat cu mina mea... dar alta logica nu vad).
Nuclear launch detected

User avatar
Silviu Ardelean
Senior
Senior
Posts: 1175
Joined: 12 Jul 2007, 09:22
Judet: Timiş
Location: Timisoara
Contact:

Re: Probleme de driver ODBC in MS. Access Driver

Post by Silviu Ardelean » 15 Dec 2010, 21:35

cristianamarie wrote:Nu man, acu imi dau seama. E un first open, si trompeta de Access are nu stiu ce dialog cind deschizi "Certain database content has been disabled"
E asta de aici: http://www.blueclaw-db.com/access_2007/ ... arning.htm
Da frate... asta e cu adevarat o trompeta. :thumbsup:
Cristi, mersi fain de link-urile cu trusted location. Le voi incerca si daca e ceva nou suflu in trompeta. :biggrin:

Post Reply