i have a code. i just want to save listview data to database. the title is the error that pops out
here is my code
Public Sub ConnectDatabase()
conn.ConnectionString = "SERVER=localhost;User id=root;database=test"
Try
conn.Open()
MessageBox.Show("Connected")
With mycommand
.CommandText = "Select * from wer"
'.ExecuteNonQuery()
End With
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
Finally
conn.Dispose()
End Try
End Sub
that is declared in my module
and here is the code for my save button
Dim iCount As Integer
Dim iLoop As Integer
Dim query3 As New MySqlCommand
Dim lvitem
ConnectDatabase()
conn.Open()
iCount = lvLogs.Items.Count
If Not lvLogs.Items.Count = 0 Then
Do Until iLoop = lvLogs.Items.Count
lvitem = lvLogs.Items.Item(iLoop)
With lvitem
.Connection = conn
.CommandText = "insert into wer values ('" & .SubItems(0).Text & "','" & .SubItems(1).Text & "','" & .SubItems(2).Text & "','" & .SubItems(3).Text & "','" & .SubItems(4).Text & "','" & .SubItems(5) & "')"
.ExecuteNonQuery()
End With
iLoop = iLoop + 1
lvitem = Nothing
MessageBox.Show("Record added!")
Loop
End If
kindly help me