listview data in Database

  • Thread starter Thread starter muhammadanzar
  • Start date Start date
M

muhammadanzar

Guest
hi,

1617315.png

my code

Dim item As New ListViewItem
Using connection As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=Students;Integrated Security=True")
For rows = 0 To ListView1.Items.Count - 1 ' grid(row, col)
For col = 0 To 3
Using command As New SqlCommand("INSERT INTO [Students].[dbo].[SaleDetail]([ProductId],[ProductName],[Quantity],[Price]) VALUES ( '" & item.Text & "', '" & item.SubItems(1).Text & "', '" & item.SubItems(2).Text & "', '" & item.SubItems(3).Text & "')", connection)

Try
connection.Open()
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("Data Save in Database", "Read Message Carefully", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2)
' ShowData()
End If
connection.Close()
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
Finally
End Try
End Using
Next
Next
End Using
kindly Guide me how can i insert records from listview to database.



MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959

Continue reading...
 

Similar threads

M
Replies
0
Views
130
muhammadanzar
M
M
Replies
0
Views
178
muhammadanzar
M
M
Replies
0
Views
135
muhammadanzar
M
M
Replies
0
Views
126
muhammadanzar
M
Back
Top