Results 1 to 5 of 5

Thread: [02/03] Access DataBase problem.....

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    82

    [02/03] Access DataBase problem.....

    Hi there
    I have a data table named "test" on the Access Database named "My_First.mdb".

    I did the followings.
    (1) Public m_connection As New OleDb.OleDbConnection
    public m_dataAdapter_test As New OleDb.OleDbDataAdapter
    Public m_commandBuilder_test As OleDb.OleDbCommandBuilder
    Public m_dt_test As New DataTable

    (2) Opened the connnection "m_connection" using the correct connection
    string

    (3) m_dataAdapter_test = New OleDb.OleDbDataAdapter("Select * from test",
    m_connection)
    m_commandBuilder_test = New OleDb.OleDbCommandBuilder(m_dataAdapter_test)
    m_dataAdapter_test.Fill(m_dt_test)

    (4) Everthig was going ok, i could edit the entries on the database except one thing.
    that's.......
    Once i add a new row, the data adapter ("m_dataAdapter") is showing correctly that the new row's been added...
    But when it's going to update it usting the following code.

    "m_dataAdapter_test.Update(.m_dt_test)" it shows the following error.


    An unhandled exception of type 'System.Data.DBConcurrencyException'
    occurred in system.data.dll

    Additional information: Concurrency violation: the UpdateCommand affected
    0 records.

    please help me to correct this error.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    82

    Re: [02/03] Access DataBase problem.....

    could anyone hlep me please............

  3. #3
    Addicted Member phenom's Avatar
    Join Date
    Apr 2006
    Location
    UAE
    Posts
    233

    Re: [02/03] Access DataBase problem.....

    Hi sriya,

    i beleive that you need to create a DataRow to add a new ROW as shown below
    VB Code:
    1. Dim dtcmp As DataRow = m_dt_test.NewRow
    2.             dtcmp("CompanyName") = txtCompany.Text
    3.             'etc
    4.             'etc
    5.             m_dt_test.Rows.Add(dtcmp)
    6.             m_DataAdapter.Update(m_dt_test)

    second this line "in ur code" has an error, there is . before m_dt_test

    "m_dataAdapter_test.Update(.m_dt_test)" it shows the following error.

    hope this helps...

    Regards,
    =======================================
    If I helped you, Kindly Rate my post. Thanks
    -----------
    PHENOM

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    82

    Re: [02/03] Access DataBase problem.....

    thanx phenom,,,
    but the data row could be added without any problem... I did it exactly in ur way & when checking the dataAdapter shows that it has the new row...
    the matter comes when the dataAdapter is updated...
    pls hlep me.

  5. #5
    Addicted Member phenom's Avatar
    Join Date
    Apr 2006
    Location
    UAE
    Posts
    233

    Re: [02/03] Access DataBase problem.....

    Hi Sriya,

    Better to post your full code "when u add a new Row"to test it... cuz the code i posted should work 100%...

    VB Code:
    1. Your Code Here

    Regards,
    Last edited by phenom; Jul 18th, 2006 at 06:01 AM.
    =======================================
    If I helped you, Kindly Rate my post. Thanks
    -----------
    PHENOM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width