M
muhammadanzar
Guest
hi,
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...
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...