Insert data records into MsAccess database using table adapters

newvbee

New member
Joined
Sep 11, 2007
Messages
2
Programming Experience
Beginner
Hello,

I'm three weeks into visual basic 2005 . I use the ms access 2003 database as a backend.
I have created a form to accept data from the user. My form also has a data grid which reads data from a table and displays it. I have done this using the dataset , and binding source. My form has a binding navigator also.
A table adapter was also generated in the process.
I want to enter data through the text boxes in the form and click on the + icon on the binding navigator toolbar . I did achieve the task to this point, and the record entered is displayed on the data grid.

but I donot see the record in my database.

Question,
How do I use the table adapter to achieve this?
One of my data entry items is a date field which gives me problems. The date is stored in the mm/dd/yyyy format in the database?

Can I get a quick reply ,please??:rolleyes:



My code is as follows


VB.NET:
Public Class frmdowntime               
' ( form downtime is the name of my form)

    Private Sub frmdowntime_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'TODO: This line of code loads data into the 'Pmsys2007DataSet.Downtime' table. 
        'You can move, or remove it, as needed.

        Me.DowntimeTableAdapter.Fill(Me.Pmsys2007DataSet.Downtime)

    End Sub

    Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles BindingNavigatorAddNewItem.Click


        Dim DataRow = Pmsys2007DataSet.Downtime.NewRow
        DataRow.Item("RigId") = Me.TextBox1.Text
        DataRow.Item("equp") = Me.TextBox2.Text
        DataRow.Item("dof") = XmlConvert.ToDateTime(Me.TextBox3.Text, "mm-dd-yyyy")
        DataRow.Item("Rof") = Me.TextBox4.Text
        DataRow.Item("tof") = Me.ListBox1.Text
        Dim tUID As UInteger

        Try
            DowntimeTableAdapter.Insert(tuid, "RigId", "equp","dof","tof", "Rof")

        Catch ex As Exception
            MessageBox.Show("Insert Failed")
        End Try

        RefreshDataset()
    End Sub


    Private Sub RefreshDataset()
        Me.DowntimeTableAdapter.Fill(Me.Pmsys2007DataSet.Downtime)
    End Sub
 
Last edited by a moderator:
Hello,

I'm three weeks into visual basic 2005 . I use the ms access 2003 database as a backend.
I have created a form to accept data from the user. My form also has a data grid which reads data from a table and displays it. I have done this using the dataset , and binding source. My form has a binding navigator also.
A table adapter was also generated in the process.
I want to enter data through the text boxes in the form and click on the + icon on the binding navigator toolbar .

Er, you would click + first, to add a new record locally

I did achieve the task to this point, and the record entered is displayed on the data grid.

but I donot see the record in my database.
Did you actually send it to the db though? THis isnt access. changes are not live. In offline data modeling, you download the data, edit it and upload it again. The form should have written the code for the save button for you.

-

Unfortunately, I have to say, youre not quite doing any of your data access correctly/how i'd expect. Please read the DW2 link in my signature, section on "Creating a simple data application"

It will answer all your questions.. Or at least do it correctly so you realise the answer! :)
 
Back
Top