Information générale
Catégorie:
Fonctions Windows API
Titre:
How can I build System DSN?
All,
I wrote some code to build ODBC DSN. But I just can build ODBC user DSN but I can not build any system DSN. I don't why.
Anyone can give me any soultion?
Ricky
The following is my code:
#DEFINE ODBC_ADD_DSN 1
#DEFINE ODBC_CONFIG_DSN 2
#DEFINE ODBC_REMOVE_DSN 3
#DEFINE vbAPINull 0
DECLARE INTEGER SQLConfigDataSource;
IN ODBCCP32.DLL;
INTEGER hwndParent,;
INTEGER fRequest ,;
STRING lpszDriver,;
STRING lpszAttributes
intRet=0
strDriver=''
strAttributes=''
strDriver = "Microsoft Visual FoxPro Driver"
strAttributes = "SourceType=DBC" + Chr(0)
strAttributes = strAttributes + "DESCRIPTION=Temp DSN" + Chr(0)
strAttributes = strAttributes + "DSN=Temp" + Chr(0)
strAttributes = strAttributes + "SourceDB=c:\pjm\database\pjm.dbc" + Chr(0)
strAttributes = strAttributes + "Exclusive=No" + Chr(0)
strAttributes = strAttributes + "Uid=" + Chr(0)
strAttributes = strAttributes + "Pwd=" + Chr(0)
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes)
If intRet =1
=MESSAGEBOX( "DSN Created")
Else
=MESSAGEBOX("Create Failed")
ENDIF
CLEAR DLLS
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement