1,105,625 Community Members

VB .Net / MS Access Not Working

Member Avatar
alsnchns
Newbie Poster
1 post since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I am trying to do simple insert, update, delete, select statements within VB .NET to access a MS Access database. I have tried all kinds of solutions offered on the web and while the code seems to work, no rows are inserted. Also, I have tried, unsuccessfully, to use the Try/Catch to see if there's an error with no success. Please advise what I'm doing wrong. I have attached the versions of VB .Net and MS Access I am using:
Here's the code:

Dim Connection_String As String
            Connection_String = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=C:\AquaticPT\AquaticPT.mdb"
            Dim dbConn As OleDbConnection = New OleDbConnection(Connection_String)
            Dim dbCMD As OleDbCommand
            Dim dr As OleDbDataReader
            Dim ds As DataSet = New DataSet
            Dim cmdstr As String
            Dim sqlQRY As String = "SELECT * FROM tbPatient"
            Dim daAdapt As OleDbDataAdapter = New OleDbDataAdapter(sqlQRY, dbConn)
            Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(daAdapt)


            dbConn.Open()
            MsgBox("db open")
            daAdapt.Fill(ds, "tbPatient")
            Dim dt As DataTable = ds.Tables("tbPatient")


            Dim dsNewRow As DataRow = dt.NewRow

            dsNewRow("PrimaryPhone") = stPrimaryPhone
            dsNewRow("FirstName") = stFirstName
            dt.Rows.Add(dsNewRow)
Attachments vbnet.bmp (167.86KB) msaccess.bmp (53.24KB)
Member Avatar
crapulency
Junior Poster in Training
53 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi alsnchns How about putting this at the end:

try
		daAdapt.Update(ds)
	catch...
Member Avatar
goldenevil
Newbie Poster
1 post since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi alsnchns
I amm not expert in vb.net but i think u should fill the dataset with the datatable

best wishes

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article