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