An unhandled exception of type 'System.NullReferenceException' occurred in System.Data.dll

An unhandled exception of type 'System.NullReferenceException' occurred in System.Data.dll

Postby Zeus73 » Thu 19 May 2005 19:41

I...

I am developing a project for windows pocket pc with vb.net and the compact framework.

I use Core Lab MySQLDirect .NET Data Provider Mobile Standart v 2.80 to access MySQL database.

I'm having a problem editing data from mysql data table.... next is my code and my table structure.... does one can tell me wath is wrong with my code!?


Imports CoreLab.MySql

Private Sub act_stkart()
Dim mCnStr As String
Dim mStrSql As String
Dim cnDataBase1_MySQL As MySqlConnection

Dim mCommand As MySqlCommand
Dim mDataAdapter As MySqlDataAdapter
Dim mCmdBuilder As MySqlCommandBuilder
Dim mDataSet As DataSet

mCnStr = "Database=dbgesuni;"
mCnStr = mCnStr & "Data Source=192.168.19.9;"
mCnStr = mCnStr & "User Id=admin;"
mCnStr = mCnStr & "Password=centers"
cnDataBase1_MySQL = New MySqlConnection(mCnStr)
cnDataBase1_MySQL.Open()

' TABLE actpda_stkart STRUCTURE
'`num_record` bigint (20) NOT NULL DEFAULT 0,
'`act` CHAR (1) NOT NULL DEFAULT 'S',
'`cod_pda` CHAR (3) NOT NULL DEFAULT '.',
'`cod_stk` varchar (7) NOT NULL DEFAULT '.',
'`nom_stk` varchar (35) NOT NULL DEFAULT '.',
'`pvp1` DOUBLE (9,2) NOT NULL DEFAULT 0.00,
'`pvp2` DOUBLE (9,2) NOT NULL DEFAULT 0.00,
'`pvp3` DOUBLE (9,2) NOT NULL DEFAULT 0.00,
'`pvp4` DOUBLE (9,2) NOT NULL DEFAULT 0.00,
'`act_pvp` INTEGER (1) NOT NULL DEFAULT 0,
'`foto` blob,
'`act_foto` INTEGER (1) NOT NULL DEFAULT 0,
'PRIMARY(KEY(num_record))
') TYPE=InnoDB

mStrSql = "select * from actpda_stkart "
mStrSql = mStrSql & "where cod_pda = '001' "
mStrSql = mStrSql & "and act = 'S' or act = 'A' "
mStrSql = mStrSql & "order by num_record "
mStrSql = mStrSql & "limit 0,500"

' MySqlCommand
mCommand = New MySqlCommand(mStrSql)
mCommand.Connection = cnDataBase1_MySQL
mCommand.ExecuteNonQuery()

' MySqlDataAdapter
mDataAdapter = New MySqlDataAdapter(mCommand)
mDataAdapter.TableMappings.Add("Table", "actpda_stkart")

' MySqlCommandBuilder
mCmdBuilder = New MySqlCommandBuilder(mDataAdapter)

' define and fill dataset
mDataSet = New DataSet
mDataAdapter.Fill(mDataSet)

'' delete record example works fine
mDataSet.Tables(0).Rows(0).Delete()
mDataAdapter.Update(mDataSet, "actpda_stkart")

' change record example gives the following system error
' 'An unhandled exception of type
' 'System.NullReferenceException' occurred in System.Data.dll
mDataSet.Tables(0).Rows(0).Item("act") = "N"
mDataAdapter.Update(mDataSet, "actpda_stkart")

End Sub
Zeus73
 

Postby Serious » Mon 23 May 2005 11:20

We have fixed this problem for the MySQLDirect .NET Mobile.
Look forward for the next build. While it is not released you need to set for your primary key column (num_record) an AUTO_INCREMENT attribute.
Serious
 

Postby Zeus73 » Mon 23 May 2005 11:45

Thank you for answer and for your time... I'll be waiting for the next release....
Zeus73
 


Return to dotConnect for MySQL