Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 27th, 2007, 03:38 AM
Registered User
 
Join Date: May 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default adding updating a table in access using vb 2005

I am using visual basic 2005 express edition. I am having problems adding and updating an access database.

My problem is updatingand not adding.

The following is the code.

Private Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
            Dim row As DataRow = dt.NewRow()
            row("deptno") = deptnobox.Text
            row("dname") = dnamebox.Text
            row("location") =locationbox.text
            dt.Rows.Add(row)
            ShowDataSet()
                    End Sub

Private Sub cmdUpdateRow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdUpdateRow.Click
Dim rows As DataRow() = dt.Select("deptno = " & deptnobox.Text)
rows(0)("dname") = dnamebox.Text
rows(0)("location") = locationbox.text
ShowDataSet()
End Sub

Private Sub cmdAccept_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAccept.Click
            ds.AcceptChanges()
            ShowDataSet()
                    End Sub

Private Sub ShowDataSet()
            lstModel.Items.Clear()
            For Each row As DataRow In dt.Rows
                If row.RowState <> DataRowState.Deleted Then
lstModel.Items.Add(row("deptno")& controlchars.tab & row("dname") & controlchars.tab & row("location"))
End If
Next row
End Sub

** ds is the dataset and connection is done conn as new oledb.oledbconnection and all other variables defined as global.

Any suggestions or opinions?




 
Old May 28th, 2007, 08:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

what is your error???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 30th, 2007, 12:41 AM
Registered User
 
Join Date: May 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is no error shown. It will add the entries to the list box and I can see that in the display of the list box.

When I click update, it has no error message. Then when the form is reloaded again I see the original entries (3).

That means it is not getting committed to the database.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Vb.net 2005 using MS Access johnnys14 SQL Language 0 July 10th, 2008 01:14 PM
How to use access 2007 databases in vb 2005? Richard C. McAdams BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 June 16th, 2008 11:48 AM
Updating databases with VB 2005 Express PatCiferri VB How-To 3 December 3rd, 2007 08:31 AM
Adding New Record to Access Database Using VB.NET TechHelp ASP.NET 1.0 and 1.1 Basics 1 September 13th, 2006 03:19 AM
Insert New Row into Table (VB 2005) adit9 Visual Basic 2005 Basics 0 March 3rd, 2006 03:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.