prederso
asked on
Connection from VB6 to .NET
I have just started looking into VB.NET but are having problems making a database connection. The connection I used in VB6 looked like this:
Set Cn = CreateObject("ADODB.Connec tion")
Cn.Open("driver={SQL Server};Server=serv1;netwo rk=ps;uid= ts;pwd=ts; database=t elesales")
What would that connection looke like in .NET??
Set Cn = CreateObject("ADODB.Connec
Cn.Open("driver={SQL Server};Server=serv1;netwo
What would that connection looke like in .NET??
ASKER
But can I use Data Source = localhost when i need to access the database on a network?
Hi prederso,
Just drag a sqlconnection from the toolbox onto your form and fill in the wizard. You can than look in the windows generated code if you are interested in the complete code.
Just drag a sqlconnection from the toolbox onto your form and fill in the wizard. You can than look in the windows generated code if you are interested in the complete code.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Use This:
Dim connString As String
Dim conn As OleDb.OleDbConnection
conn=new OleDb.OleDbConnection
connString = "Provider=sqloledb;Data Source=localhost;User Id=sa;Initial Catalog=Pubs;"
conn = New OleDbConnection
conn.ConnectionString = connString
conn.Open()
Regards
Anil Poonia