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

Visual Basic .NET (7.1): same as VB 6.0?

Status
Not open for further replies.

christywarner

Programmer
Apr 14, 2003
32
0
0
US
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.
 
The connection string for ADO.NET is indeed different than the one that ADO (VB6 style) used. If you search for "ConnectionString" (all one word) in the .NET help it will detail it. Or you can search here, in the VB.NET forum, as this question has been answered there before.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Or add a DBdatadapter control to a form, point it to an existing data base and take the string out of the Connectionstring property of the addedd DBconnection control.

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top