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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help connecting to a SQL Server database. 1

Status
Not open for further replies.

rarubio1

Programmer
Jan 25, 2002
64
US
Hello everyone,
I used the following ADO/OLEDB connection string to connect to a SQL Server database using VB6:

Dim SQLserverCn As ADODB.Connection
Set SQLserverCn = New ADODB.Connection
SQLserverCn.Open "Driver=SQL Server;Server=Server1;" & _
"Database=Scheduling;UID=SA;PWD=User1"

This connection string does not work in VB.Net. Can any please let me know what syntax to use for this type of connection in VB.Net?

Thank you,
R. Rubio
 
The following should help: :)
Write this line at the top of your code page
Imports System.Data.OleDb

Then include this at the place where u want to establish a DB conn with sql server

Dim cConnString As String
Dim oConn As New OleDbConnection()
cConnString = "Provider= SQLOLEDB;data source = server1;initial catalog = Scheduling;user id = SA;Password = User1"
oConn.ConnectionString = cConnString
'open connection with db
oConn.Open()




Cheers!
 
Thanks Jan11, I will use your suggestion and let you know hot it goes.

R.Rubio :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top