|
-
Jul 8th, 2004, 09:23 AM
#1
Thread Starter
Fanatic Member
Create DSN
Can anybody give me an example of how to create a DSN in code using SQLConfigDataSource please.
Banging my head against a brick wall!!
VB6 sp5, SQL Server 2000, C#
There are no stupid questions. Only stupid people. 
-
Jul 28th, 2004, 08:39 AM
#2
Addicted Member
Hi,
I use this code to create a DSN... you can control if it is a user or system dsn by opening the Registry.LocalMachine or Registry.CurrentUser methods respectively. All I did to check this was create a DSN, look at what happens in the registry, then take each value from the registry and ensure that the code below actually populates the registry with the relevant information.
Also, I think you need to include the Microsoft.Win32.Registry or something like that at the top of your code.
Code:
RegistryKey r = Registry.LocalMachine.CreateSubKey("SOFTWARE\\ODBC\\ODBC.INI\\DSN NAME");
r.SetValue("BufferSize","65535");
r.SetValue("Description","Connection");
r.SetValue("Driver","C:\\Windows\\System32\\msorcl32.dll");
r.SetValue("DSN","DSN NAME");
r.SetValue("GuessTheColDef","0");
r.SetValue("PWD","");
r.SetValue("Remarks","0");
r.SetValue("SERVER","oracleserver");
r.SetValue("StdDayOfWeek","1");
r.SetValue("StripTrailingZero","0");
r.SetValue("SynonymColumns","1");
r.SetValue("UID","me");
r.Close();
r = Registry.LocalMachine.OpenSubKey("SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources\\",true);
r.SetValue("DSN NAME","Microsoft ODBC for Oracle");
r.Close();
Hope this helps?
DJ
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
|