Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Getting Windows Auth to work with DSN

Status
Not open for further replies.

ChadJK

IS-IT--Management
Nov 10, 2005
14
0
0
US
I'm using the following bit of code to generate a DSN, but it seems to keep setting it up to use SQL Server authentication and I want it to use the integrated Windows Authentication:

Code:
using System.Runtime.InteropServices;

[DllImport("ODBCCP32.DLL")]

private static extern bool SQLConfigDataSource(IntPtr parent, int request, string driver, string attributes);

SQLConfigDataSource((IntPtr)0, 4, "SQL Server\0", "SERVER=sql-dev\\sql2k5dev\0DESCRIPTION=DRI Production Database\0DSN=DRI2\0DATABASE=DRI\0");
 
I figured it out finally...

Code:
using System.Runtime.InteropServices;

[DllImport("ODBCCP32.DLL")]

private static extern bool SQLConfigDataSource(IntPtr parent, int request, string driver, string attributes);

SQLConfigDataSource((IntPtr)0, 4, "SQL Server\0", "SERVER=sql-dev\\sql2k5dev\0DESCRIPTION=DRI Production Database\0DSN=DRI2\0DATABASE=DRI\0TRUSTED_CONNECTION=YES\0");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top