We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,151 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Best way to connect to database

I am totally new to vb.net, still I am planning to try it for a project, in which there will be standalone machine using an access database to query and update different tables.

While in VB6 I was able to define recordsets using Microsoft.jet.oledb.4.0, in VB.net I have become a little confused.

I plan to define a global connection to the access database:

Dim TheConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0; data source=|DataDirectory|\office.mdb;Persist Security Info=True;Jet OLEDB:Database Password=1234")

Depending on what the user has selected, a sql command is created, e.g.

Dim SQL_CUSTOMERS As OleDbCommand = New OleDbCommand("SELECT * FROM CUSTOMERS;", TheConnection)

A list of customers can be filled as follows:

        Try
            TheConnection.Open()

            Dim reader As OleDbDataReader
            reader = SQL_CUSTOMERS.ExecuteReader()

            Do While reader.Read()
                lst_kunden.Items.Add(reader.Item("COMPANY"))
            Loop

            reader.Close()
            TheConnection.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

The question is:

I want to display a MsgBox if there are no data available. Also is there a way to define recordsets?

I appreciate your help.

1
Contributor
1
Reply
1 Hour
Discussion Span
4 Months Ago
Last Updated
2
Views
Question
Answered
Baradaran
Junior Poster
104 posts since Feb 2007
Reputation Points: 11
Solved Threads: 8
Skill Endorsements: 0

What is best to use in VB NET in place of the VB6 adodb.recordset?

Google provided some links, in which I found a few tips.

Baradaran
Junior Poster
104 posts since Feb 2007
Reputation Points: 11
Solved Threads: 8
Skill Endorsements: 0
Question Self-Answered as of 4 Months Ago

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0624 seconds using 2.65MB