Create System DSN on the fly?? 
Author Message
 Create System DSN on the fly??

Can anyone help me about create System DSN on the fly?

I'v searched MSDN. The function ConfigDSN and SQLConfigDataSource has the
ability to do. How do I use it?

Thanks in advance.

Yu Cheng



Tue, 11 Mar 2003 03:00:00 GMT  
 Create System DSN on the fly??
Haven't you answered your own question?  The MSDN is pretty clear on
what you need to do.  If you're unclear about what to put in, try
creating one using ODBC applet in Control Panel and then taking a lot at
the contents.  The system DSN's are in the registry key:

HKLM/Software/ODBC/ODBC.INI/ODBC Data Sources

The user DSN's are in the same key under HKCU instead of HKLM.

For on the fly stuff, though, I prefer to use a file DSN.  They're just
the same as user or system DSN's and I find the file system functions
are more familiar.  To use a file DSN instead of a system or user DSN,
simply change your "DSN=xxxxx" connection string to "FILEDSN=yyyyy"
where yyyyy is the name of your file.  Again, if you want to see what
one looks like, use the ODBC Control Panel applet to create one and then
take a peek at the file.

/Martin

Quote:
-----Original Message-----

Posted At: Friday, September 22, 2000 5:21 PM
Posted To: database
Conversation: Create System DSN on the fly??
Subject: Create System DSN on the fly??

Can anyone help me about create System DSN on the fly?

I'v searched MSDN. The function ConfigDSN and SQLConfigDataSource has
the
ability to do. How do I use it?

Thanks in advance.

Yu Cheng



Fri, 14 Mar 2003 03:00:00 GMT  
 Create System DSN on the fly??

Thanks Martin but...

I think I need to create SysDSN as our core COM object only work with DSN
not fileDSN.

According to the info from MSDN, it look prety simple but I failed. I 'v
tried like this:

BOOL bRet = ::SQLConfigDataSource(NULL,ODBC_ADD_DSN, "SQL Server",
                                                               "DSN=MyDSN\0"
                                                                "UID=MyID\0"
                                                                "PWD=\0"

"DATABASE=MyDB\0");

When run it, bRet is 0 but in register key under
HKLM/Software/ODBC/ODBC.INI/ODBC Data Sources
is not there.

However, I tried to remove an existing DSN but not removed :
BOOL bRet = ::SQLConfigDataSource(NULL,ODBC_REMOVE_DSN, "SQL Server",
"DSN=MyExistedDSN\0");

Any suggestion?

Thank you in advance.



Quote:
> Haven't you answered your own question?  The MSDN is pretty clear on
> what you need to do.  If you're unclear about what to put in, try
> creating one using ODBC applet in Control Panel and then taking a lot at
> the contents.  The system DSN's are in the registry key:

> HKLM/Software/ODBC/ODBC.INI/ODBC Data Sources

> The user DSN's are in the same key under HKCU instead of HKLM.

> For on the fly stuff, though, I prefer to use a file DSN.  They're just
> the same as user or system DSN's and I find the file system functions
> are more familiar.  To use a file DSN instead of a system or user DSN,
> simply change your "DSN=xxxxx" connection string to "FILEDSN=yyyyy"
> where yyyyy is the name of your file.  Again, if you want to see what
> one looks like, use the ODBC Control Panel applet to create one and then
> take a peek at the file.

> /Martin

> -----Original Message-----

> Posted At: Friday, September 22, 2000 5:21 PM
> Posted To: database
> Conversation: Create System DSN on the fly??
> Subject: Create System DSN on the fly??

> Can anyone help me about create System DSN on the fly?

> I'v searched MSDN. The function ConfigDSN and SQLConfigDataSource has
> the
> ability to do. How do I use it?

> Thanks in advance.

> Yu Cheng



Fri, 14 Mar 2003 03:00:00 GMT  
 Create System DSN on the fly??
According to MSDN, SQLConfigDataSource returns TRUE or FALSE so if bRet
is 0 (i.e. FALSE) you're not doing very well.  MSDN also reports that
you can call SQLInstallerError to get a more specific error message.

Looking at your code, however, I'm not sure how you expect it to work.
You haven't specified a Server or Initial Catalog in the Attributes.
Probably the SQL Server driver defaults to your local system for the
Server and Master for the initial catalog but it's a good idea to
specify them, i.e. Server and Initial Catalog.

If I'm right and the default is for the driver to look to the local
system for the server, do you have SQL Server installed on the local
system?  If you do, is the User ID correct and does it work with a NULL
password?  Make sure to run SQLInstallerError to see what sort of error
you are getting.

/Martin

Quote:
-----Original Message-----

Posted At: Monday, September 25, 2000 11:51 AM
Posted To: database
Conversation: Create System DSN on the fly??
Subject: Re: Create System DSN on the fly??

Thanks Martin but...

I think I need to create SysDSN as our core COM object only work with
DSN
not fileDSN.

According to the info from MSDN, it look prety simple but I failed. I 'v
tried like this:

BOOL bRet = ::SQLConfigDataSource(NULL,ODBC_ADD_DSN, "SQL Server",

"DSN=MyDSN\0"

"UID=MyID\0"
                                                                "PWD=\0"

"DATABASE=MyDB\0");

When run it, bRet is 0 but in register key under
HKLM/Software/ODBC/ODBC.INI/ODBC Data Sources
is not there.

However, I tried to remove an existing DSN but not removed :
BOOL bRet = ::SQLConfigDataSource(NULL,ODBC_REMOVE_DSN, "SQL Server",
"DSN=MyExistedDSN\0");

Any suggestion?

Thank you in advance.




> Haven't you answered your own question?  The MSDN is pretty clear on
> what you need to do.  If you're unclear about what to put in, try
> creating one using ODBC applet in Control Panel and then taking a lot
at
> the contents.  The system DSN's are in the registry key:

> HKLM/Software/ODBC/ODBC.INI/ODBC Data Sources

> The user DSN's are in the same key under HKCU instead of HKLM.

> For on the fly stuff, though, I prefer to use a file DSN.  They're
just
> the same as user or system DSN's and I find the file system functions
> are more familiar.  To use a file DSN instead of a system or user DSN,
> simply change your "DSN=xxxxx" connection string to "FILEDSN=yyyyy"
> where yyyyy is the name of your file.  Again, if you want to see what
> one looks like, use the ODBC Control Panel applet to create one and
then
> take a peek at the file.

> /Martin

> -----Original Message-----

> Posted At: Friday, September 22, 2000 5:21 PM
> Posted To: database
> Conversation: Create System DSN on the fly??
> Subject: Create System DSN on the fly??

> Can anyone help me about create System DSN on the fly?

> I'v searched MSDN. The function ConfigDSN and SQLConfigDataSource has
> the
> ability to do. How do I use it?

> Thanks in advance.

> Yu Cheng



Sun, 16 Mar 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to create a DSN on the fly

2. How to create a DSN on the fly

3. How to define and create a system DSN with VC functions

4. How to create a system DSN in Visual C++??Thank you

5. Programatically Creating System DSN's

6. How to change DSN for recordsets on the fly

7. User DSN vs Sys DSN vs File DSN.

8. Unhandled Exception: System.Configuration.ConfigurationException: Could not create System Configuration.NameValueSectionHandler, System

9. ODBC SYSTEM DSN

10. CDatabase Can't Open System DSN with ODBC 3.0 SDK

11. System DSN details from program??

12. Problem cnnecting through to a System DSN

 

 
Powered by phpBB® Forum Software