Bug #56903 MySqlDataAdapter datatable update fail on empty table
Submitted: 21 Sep 2010 17:03 Modified: 22 Sep 2010 6:57
Reporter: Olivier Olivier Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:5.2.7 OS:Windows (Vista)
Assigned to: CPU Architecture:Any
Tags: datatable update fail first row

[21 Sep 2010 17:03] Olivier Olivier
Description:
Hi,

I encounter a problem when trying to insert first row of an empty table

When calling update datatable, I get an error 

"Object reference is not defined to an object instance"

This error disappear if I previously inserted manually a first row.

Can you help me to understand ?

Thanks a lot.

How to repeat:
VB.net

 Structure S_table
        Dim data As DataTable
        Dim da As MySqlDataAdapter
        Dim cb As MySqlCommandBuilder
    End Structure

sql="Select * from tags;"
tags.data = New DataTable
tags.da = New MySqlDataAdapter(sql, conn)
tags.cb = New MySqlCommandBuilder(tags.da)
tags.da.Fill(tags.data)

tags.data.Rows.Add()
p_rec = tags.data.Rows.Count - 1
tags.data.Rows(p_rec).Item("tg_txt") = lbl.Text

tags.da.Update(tags.data) <= error message
tags.data.AcceptChanges()
[22 Sep 2010 6:13] Tonci Grgin
Hi Olivier and thanks for your report.

Version 5.x is long deprecated. Please use 6.2 or 6.3 when reporting problems.
[22 Sep 2010 6:57] Olivier Olivier
OK, thanks.