Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > Visual Studio 2008
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old June 24th, 2010, 07:13 AM
Registered User
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Post Save Records in listview items to SQL Database


I was able to save data in sql but i can't save multi rows in listview items,
please can any one help out.the code is give below.

Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click

Dim intPosition As Integer
Dim strdt As Date
Dim objCommand As SqlCommand = New SqlCommand()
intPosition = objCurrencyManager.Position
strdt = dtp1.Value
objCommand.Connection = objConnection
objCommand.CommandText = "INSERT INTO First_Assortment_Received" & _
"(e_no,part_no,lot_no,date,s_no,p_code,p_than, pwt ) " & _
"VALUES(@e_no,@part_no,@lot_no,@date,@s_no,@p_code ,@p_than,@pwt)"

Dim intMaxID As Integer = lstView.Items.Count
Dim lstStuff As ListViewItem = New ListViewItem()
objCommand.Parameters.AddWithValue("@e_no", txtEntryId.Text)
objCommand.Parameters.AddWithValue("@part_no", txtPartNumber.Text)
objCommand.Parameters.AddWithValue("@lot_no", txtLotNumber.Text)
objCommand.Parameters.AddWithValue("@date", strdt)
objCommand.Parameters.AddWithValue("@s_no", lstView.Items(0).Text)
objCommand.Parameters.AddWithValue("@p_code", lstView.Items(0).SubItems(1).Text)
objCommand.Parameters.AddWithValue("@p_than", lstView.Items(0).SubItems(2).Text)
objCommand.Parameters.AddWithValue("@pwt", lstView.Items(0).SubItems(3).Text)

For i = 1 To intMaxID
Catch SqlExceptionErr As SqlException
End Try

objCurrencyManager.Position = intPosition
ToolStripStatusLabel1.Text = "Record Added"
GroupBox1.Enabled = False
GroupBox2.Enabled = True
End Sub
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Save Listview Data to a DataBase ecabralrojas Beginning VB 6 0 June 30th, 2008 10:33 AM
Change color of items in a ListView eresina Pro VB 6 4 April 11th, 2007 09:47 AM
how to update table with listview items Singh591 Pro VB.NET 2002/2003 0 December 30th, 2006 10:13 PM
Listview doesnt change after items are selected. hexOffender VB.NET 2002/2003 Basics 0 December 13th, 2006 11:28 AM
Writting listview items to xml document chandler7272 C# 0 June 12th, 2006 06:01 AM

All times are GMT -4. The time now is 07:02 PM.

Powered by vBulletin®
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.