Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How create system DSN[odbc]-Programmatically in VB

Author  Topic 

nlbnalin
Starting Member

6 Posts

Posted - 2004-08-10 : 23:30:06
How to create System DSN [ODBC] Programmatically using VB with Window NT authentication mode? I found the code to create ODBC in VB, but it create ODBC with - “SQL Server authentication using login and password. Please Help me

---------------Following code I Used-----------------------
#If WIN32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String

'Set the driver to SQL Server because it is most common.
strDriver = "SQL Server"
'Set the attributes delimited by null.
'See driver documentation for a complete
'list of supported attributes.
strAttributes = "SERVER=SomeServer" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=Temp DSN" & Chr$(0)
strAttributes = strAttributes & "DSN=DSN_TEMP" & Chr$(0)
strAttributes = strAttributes & "DATABASE=pubs" & Chr$(0)
'To show dialog, use Form1.Hwnd instead of vbAPINull.
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, _
strDriver, strAttributes)
If intRet Then
MsgBox "DSN Created"
Else
MsgBox "Create Failed"
End If


Regads
Nalin

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-08-11 : 12:07:50
Why do you want to use ODBC though? It is recommended to use OLEDB instead now.

Tara
Go to Top of Page
   

- Advertisement -