Cannot create DSN name
-
Hi sir, I want to create a DSN Name and set a path for that. I am using "SQLConfigDataSource" function for this. It is not giving any error and running properly.But it is not writing to DNS. Here ia wat i am doing
SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
Am i doing right???or any other stuff need to be done. Thanks Raj
-
Hi sir, I want to create a DSN Name and set a path for that. I am using "SQLConfigDataSource" function for this. It is not giving any error and running properly.But it is not writing to DNS. Here ia wat i am doing
SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
Am i doing right???or any other stuff need to be done. Thanks Raj
Did you check the return value? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Did you check the return value? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Hi, I tried with this
bool aDSNCreated = false;
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
printf("%d",aDSNCreated );aDSNCreated value is zero. what i am doing wrong?? Thanks Raj
-
Hi, I tried with this
bool aDSNCreated = false;
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
printf("%d",aDSNCreated );aDSNCreated value is zero. what i am doing wrong?? Thanks Raj
When SQLConfigDataSource returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
When SQLConfigDataSource returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Hi sir.
CPallini wrote:
an associated *pfErrorCode value can be obtained by calling SQLInstallerError
I am not getting how to get the errorcode.I am trying as below
bool aDSNCreated = false;
//char *str;// = "asdasdsd\0";
RETCODE retcode= SQL_SUCCESS;
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
printf("%d",aDSNCreated );
if(aDSNCreated == false)
{
retcode = SQLInstallerError(2, NULL,NULL,100,NULL);}
I am not getting wat paramaters to send and return the error code.. please help me out. Sorry i know its a very silly question. Thanks Raj
-
Hi sir.
CPallini wrote:
an associated *pfErrorCode value can be obtained by calling SQLInstallerError
I am not getting how to get the errorcode.I am trying as below
bool aDSNCreated = false;
//char *str;// = "asdasdsd\0";
RETCODE retcode= SQL_SUCCESS;
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
printf("%d",aDSNCreated );
if(aDSNCreated == false)
{
retcode = SQLInstallerError(2, NULL,NULL,100,NULL);}
I am not getting wat paramaters to send and return the error code.. please help me out. Sorry i know its a very silly question. Thanks Raj
I would do:
BOOL isDSNCreated;
isDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
if (isDSNCreated == FALSE)
{
CHAR szError[SQL_MAX_MESSAGE_LENGTH];
DWORD dwError;
WORD cbError;
RETCODE retcode;
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
// check 'retcode', have a look at 'dwError', show 'szError', whatever...
}If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I would do:
BOOL isDSNCreated;
isDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
if (isDSNCreated == FALSE)
{
CHAR szError[SQL_MAX_MESSAGE_LENGTH];
DWORD dwError;
WORD cbError;
RETCODE retcode;
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
// check 'retcode', have a look at 'dwError', show 'szError', whatever...
}If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]CPallini wrote:
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
Hi sir, I am getting this error:
Error 47 error C2664: 'SQLInstallerErrorW' : cannot convert parameter 3 from 'CHAR [512]' to 'LPWSTR'
Thanks Raj
-
CPallini wrote:
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
Hi sir, I am getting this error:
Error 47 error C2664: 'SQLInstallerErrorW' : cannot convert parameter 3 from 'CHAR [512]' to 'LPWSTR'
Thanks Raj
The use:
TCHAR szError[SQL_MAX_MESSAGE_LENGTH];
DWORD dwError;
WORD cbError;
RETCODE retcode;
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
The use:
TCHAR szError[SQL_MAX_MESSAGE_LENGTH];
DWORD dwError;
WORD cbError;
RETCODE retcode;
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Hi sir, Thank you.Its building without error. I am getting the retcode as zero(i.e SQL_SUCCESS). But i am not finding the DSN Created when i am checking through Control Panel->ODBC Thanks Raj