Hi, I thought I'd share this with you guys:
I looked for some examples on how to connect to SQL Server using ADO.NET but did not find much...
This worked for me:
Add an adodb Reference to your project.
Public Conn as ADODB.Connection
Public STR as String
Private Sub Connect (ByVal Server as String, ByVal UID as String, ByVal Pwd as String, ByVal DB as String)
Conn = New ADODB.Connection
Conn.ConnectionTimeout = 3000
STR = "Provider=SQLOLEDB.1;Initial Catalog=" & DB & ";Data Source=" & Server & ";User ID= & UID & ";password=" & Pwd
Conn.Open (STR)
End Sub
Now simply call the subroutine:
Connect <yourserver>, <userid>, <password>, <databasename>
any suggestions, remarks, etc... are more than welcome.
MartinLG




Reply With Quote