输入字符串的格式不正确以及如何重命名行标题 datagridview
Input string was not in a correct format & how to rename rowheader datagridview
请编码解决方案并重命名行 header 我的意思是标记我附加的图像文件的颜色
注意:对于笔记,我使用 visual studio 2010
Public Class Form1
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
dbConnection()
Dim indexID As Integer
x = DataGridView1.Rows.IndexOf(DataGridView1.CurrentRow)
indexID = Convert.ToInt32((DataGridView1.Rows(x).Cells(0).Value.ToString()))
sql = "UPDATE ITEM SET ITM= '" & txtFname.Text & "',ITC='" & txtLname.Text & "',QOH='" & cbGender.Text & "' WHERE ID=" & indexID & ""
cmd = New OleDbCommand(sql, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully Updated...", "Update")
conn.Close()
'btnReadDatabase_Click(sender, e);
retrieveALL()
End Sub
End Class
object reference not set
谢谢
罗伊
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
dbConnection()
sql = "UPDATE ITEM SET ITM= '" & txtFname.Text & "',ITC='" & txtLname.Text & "',QOH='" & cbGender.Text & "' WHERE ITC='" & txtLname.Text & "'"
cmd = New OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully Updated...", "Update")
con.Close()
PopulateDataGridView()
End Sub
请编码解决方案并重命名行 header 我的意思是标记我附加的图像文件的颜色 注意:对于笔记,我使用 visual studio 2010
Public Class Form1
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
dbConnection()
Dim indexID As Integer
x = DataGridView1.Rows.IndexOf(DataGridView1.CurrentRow)
indexID = Convert.ToInt32((DataGridView1.Rows(x).Cells(0).Value.ToString()))
sql = "UPDATE ITEM SET ITM= '" & txtFname.Text & "',ITC='" & txtLname.Text & "',QOH='" & cbGender.Text & "' WHERE ID=" & indexID & ""
cmd = New OleDbCommand(sql, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully Updated...", "Update")
conn.Close()
'btnReadDatabase_Click(sender, e);
retrieveALL()
End Sub
End Class
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
dbConnection()
sql = "UPDATE ITEM SET ITM= '" & txtFname.Text & "',ITC='" & txtLname.Text & "',QOH='" & cbGender.Text & "' WHERE ITC='" & txtLname.Text & "'"
cmd = New OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully Updated...", "Update")
con.Close()
PopulateDataGridView()
End Sub