Hai All,
How to create a System DSN dynamically for SQl Server using C#.
Please give me the Code .
Thanx,
Karthik.A
![]() |
0 |
![]() |
Hi All,
Finally i found the solution.
using Microsoft.Win32;
using System.Runtime.InteropServices;
[
DllImport("ODBCCP32.dll")
]
private static extern bool SQLConfigDataSource(IntPtr parent, int request, string driver, string attributes);On Button Click use this code
string str = "SERVER=SimplesSolveSRV\0DSN=KarthikDSN\0DESCRIPTION=NewDSN\0DATABASE=PlaySystemWeb\0TRUSTED_CONNECTION=YES";
SQLConfigDataSource((IntPtr)0,4,"SQL Server",str);SQLConfigDataSource Parameter 2 = 1 - UserDSN,4 - SystenDSN
Regards,
Karthik.A
![]() |
0 |
![]() |
i am getting error when i tried this code, do i have to add any references to make it work??
regards
Rajeeva
![]() |
0 |
![]() |