christywarner
Programmer
I am new to VB, and have VB.Net 7.1. from Visual Studio Net. I wanted to know if VB.Net uses the same syntax as VB 6.0? The connection string proprerty seems different;
here is what i have to use to connect to an Access DB:
Public Sub ConnectToAccess()
Dim conn As New System.Data.OleDb.OleDbConnection
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & text1.Text & ";"
Try
conn.Open()
' Insert code to process data.
Catch ex As Exception
MessageBox.Show("Failed to connect to data source"
Finally
conn.Close()
End Try
End Sub
In my books, it always says "set CN = new ADODB.connection"
then CN.connectionstring = "name of db"
then CN.open
it seems like it should be easier than the sub I included above?
Thanks,
Christy.
here is what i have to use to connect to an Access DB:
Public Sub ConnectToAccess()
Dim conn As New System.Data.OleDb.OleDbConnection
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & text1.Text & ";"
Try
conn.Open()
' Insert code to process data.
Catch ex As Exception
MessageBox.Show("Failed to connect to data source"
Finally
conn.Close()
End Try
End Sub
In my books, it always says "set CN = new ADODB.connection"
then CN.connectionstring = "name of db"
then CN.open
it seems like it should be easier than the sub I included above?
Thanks,
Christy.