我现在使用“wilko”的代码。但最后我想保存,我得到了错误。
Dim dict As New Dictionary(Of String, Integer)
Try
dict.Add("Index 1", 1)
dict.Add("Index 2", 2)
dict.Add("Index 3", 3)
dict.Add("Index 4", 4)
cmbIndex.DataSource = New BindingSource(dict, Nothing)
cmbIndex.DisplayMember = "Key"
cmbIndex.ValueMember = "Value"
Catch ex As Exception
End Try
.CommandText = "INSERT INTO tblMasterAksesJalanSKRD (kode_perus, nm_perusahaan, nm_pimpinan, alamat, volume, lokasi, masa_berlaku, tgl_exp, index, foto) VALUES (@a0,@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9)"
.Parameters.Add("@a0", OleDbType.VarChar).Value = txtkode.Text
.Parameters.Add("@a1", OleDbType.VarChar).Value = txtnmperus.Text
.Parameters.Add("@a2", OleDbType.VarChar).Value = txtnmpim.Text
.Parameters.Add("@a3", OleDbType.VarChar).Value = txtalamat.Text
.Parameters.Add("@a4", OleDbType.VarChar).Value = txtvol.Text
.Parameters.Add("@a5", OleDbType.VarChar).Value = txtlok.Text
.Parameters.Add("@a6", OleDbType.VarChar).Value = txtmasber.Text
.Parameters.Add("@a7", OleDbType.DBDate).Value = Date.Now
.Parameters.Add("@a8", OleDbType.VarChar).Value = cmbIndex.SelectedValue ***(i still got error on this "Additional information: Syntax error in INSERT INTO statement.")***
.Parameters.Add("@a9", OleDbType.Binary).Value = IIf(pb1.Image IsNot Nothing, arrimage, DBNull.Value)
非常感谢
来自印度尼西亚的问候。
答案 0 :(得分:0)
你的绑定不会那样。尝试使用字典并创建新的绑定源:
Dim dict As New Dictionary(Of String, Integer)
dict.Add("Kota", 6000)
dict.Add("Kabupaten", 5000)
cmbIndex.DataSource = New BindingSource(dict, Nothing)
cmbIndex.DisplayMember = "Key"
cmbIndex.ValueMember = "Value"
现在应该有以下工作:
.Parameters.add("@a8", OleDbType.VarChar).Value = cmbIndex.SelectedValue