私はここに初心者です。(DataGridView の削除部分) に関するエラーが発生しており、自己解決できないため、ここに来てガイドを求めて助けてください pls....あなたの支援に感謝します!
データ読み込みイベント
`Public Sub loadtoDGV()
Dim sqlq As String = "SELECT * FROM chattbl"
Dim sqlcmd As New SqlCommand
Dim sqladpt As New SqlDataAdapter
Dim tbl As New DataTable
With sqlcmd
.CommandText = sqlq
.Connection = conn
End With
With sqladpt
.SelectCommand = sqlcmd
.Fill(tbl)
End With
DataGridView1.Rows.Clear()
For i = 0 To tbl.Rows.Count - 1
With DataGridView1
.Rows.Add(tbl.Rows(i)("ChatConttentID"), tbl.Rows(i)("Title"), tbl.Rows(i)("ChatContent"), tbl.Rows(i)("ChatDateTime"), tbl.Rows(i)("Username"))
End With
Next
conn.Close()
End Sub`
部品削除エラーが発生しました
`If conn.State = ConnectionState.Closed Then
conn.Open()
End If
For i = 0 To DataGridView1.Rows.Count - 1
Dim deletemore As Integer = DataGridView1.SelectedRows(i).Cells(0).Value <------{line occurred error}
Dim sqlq As String = ("DELETE FROM chattbl WHERE ChatConttentID = " & deletemore & "")
Dim sqlcmd As New SqlCommand
With sqlcmd
.CommandText = sqlq
.Connection = conn
.ExecuteNonQuery()
End With
Next
loadtoDGV()`