first, i am sorry if i can't speak english well
i have problem where i can't insert data to data base mySQl using vb2005.
it is my simple code on vb.
----------------------------------
Imports MySql.Data
Imports MySql.Data.MySqlClient
Public Class Form1
Dim xobjConnection As New MySqlConnection("Server=localhost;uid=root;pwd=;database=test1;")
Dim xobjAdapter As New MySqlDataAdapter()
Dim xobjDataSet As DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nim As String
Dim nama As String
nim = Me.TextBox1.Text
nama = Me.TextBox2.Text
Dim xobjCommand As MySqlCommand = New MySqlCommand()
xobjCommand.Connection = Me.xobjConnection
xobjCommand.CommandText = "INSERT INTO apple " & _
"( nama, nim ) " & _
"VALUES ( @nama, @nim)"
xobjCommand.Parameters.AddWithValue("@nim", nim)
xobjCommand.Parameters.AddWithValue("@nama", nama)
Me.xobjConnection.Open()
Try
xobjCommand.ExecuteNonQuery()
Catch mySqlExceptionErr As MySqlException
MessageBox.Show(mySqlExceptionErr.Message)
End Try
Me.xobjConnection.Close()
End Sub
End Class
--------------------------------
the message of this error is "column nim cannot be null"
// i use 2 input box, and 1 button.
// use phptriad.
// database = test1
// database = apple -> table = apple
// database = apple -> table = apple -> field = nim (varchar) primary key
-> field = nama (varchar) not primary key
// i used the newst mySQL_ connector
// used visualstudio2005
Please help me.
sorry, and thanks (n_n)