Advertisement

03.17.2005 at 09:11AM PST, ID: 21354790
[x]
Attachment Details

Adding data to a table

Asked by karthikram in Microsoft Visual Basic.Net

Tags: sub, btnadd_click, btncommit_click

I am trying to add a data to a table . The row is created and the primary key is assigned initially. but when i enter the data in the form and hit commit the error says its already been created.
// Button Add
  Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
           Try
            dsNewRow = DsSwLib.Tables("SoftwareLibrary").NewRow()
// primary key assigned during creation of row in the table
            dsNewRow.Item("CEAT ID Number") = CeatID.Text
           'dsNewRow.Item("Manufacturer") = TextBox10.Text
            Me.OleDbDataAdapter1.Update(DsSwLib, "SoftwareLibrary")
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error")
        End Try
    End Sub

// Button Click
    Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click
           Try
             DsSwLib.Tables("SoftwareLibrary").Rows.Add(dsNewRow)
             Me.OleDbDataAdapter1.Update(DsSwLib, "SoftwareLibrary")
            Me.DsSwLib.AcceptChanges()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error")
        End Try
    End SubStart Free Trial
[+][-]03.17.2005 at 09:12AM PST, ID: 13567027

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.17.2005 at 09:42AM PST, ID: 13567318

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.17.2005 at 09:47AM PST, ID: 13567368

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: sub, btnadd_click, btncommit_click
Sign Up Now!
Solution Provided By: karthikeyanTP
Participating Experts: 1
Solution Grade: B
 
 
[+][-]03.18.2005 at 06:44AM PST, ID: 13574827

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2005 at 09:49AM PST, ID: 13576767

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.22.2005 at 06:08AM PST, ID: 13601021

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.22.2005 at 08:02AM PST, ID: 13602424

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32