Dynamically Create System DSN for SQL Server using C#

Hai All,

How to create a System DSN dynamically for SQl Server using C#.

Please give me the Code .

Thanx,

Karthik.A

0
aks_karthik
7/17/2006 7:07:37 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

2 Replies
1499 Views

Similar Articles

[PageSpeed] 34

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
aks_karthik
7/18/2006 5:35:49 AM

i am getting error when i tried this code, do i have to add any references to make it work??

 regards

Rajeeva

0
rajeevanagaraj
8/26/2008 6:36:59 AM
Reply:

Web resources about - Dynamically Create System DSN for SQL Server using C# - asp.net.object-datasource

iPhone 5 A6 chip to dynamically up-clock up to 1.3GHz (and downclock too)?
Interesting video from our friends at TLDToday: If this is not just a Geekbench app glitch, it could indicate why that A6 processor is so 2X ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

iPhone 5 Lightning port dynamically reassigns pins
... of Apple's Lightning USB cable shows that the pins on the plug aren't arranged symmetrically, suggesting that the Lightning port can dynamically ...

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 1/6/2016 1:15:53 PM