Problem in storing values from listview to database

selvakumar_82

Member
Joined
Nov 29, 2005
Messages
6
Programming Experience
Beginner
How to store a listview values into database,

i have one listview , if i click button ,all the values in listview sholud store in a oracle database,

if any1 have a source code , try to send .........
 
Do you know how to use ADO.NET to interact with a database? If not then you really need to do some reading on the subject. Basically, you get the values displayed in a ListView via the Text property of each Item and Subitem. They are all String objects so if they represent different types of data then it's up to you to convert them. Once you have the values you can populate a DataTable with them and use ADO.NET to save that data to your database.
 
something like"
VB.NET:
[COLOR=blue]Dim [/COLOR]lvitem [COLOR=blue]as[/COLOR] ListViewItem
 
[COLOR=blue]For each[/COLOR] lvitem [COLOR=blue]in[/COLOR] ListView1.Items
strSQL = "INSERT INTO myTable (myField1, myField2, myField3) VALUES " & _
"('" & lvitem.Subitems(0).Text & "', '" & lvitem.Subitems(1).Text & "', '" & lvitem.Subitems(2).Text & "')"
[COLOR=darkgreen]'notice that say lvitem.Subitems(0).Text will take the values of first column while lvitem.Subitems(1).Text from 2nd column etc.[/COLOR]
cmd = [COLOR=blue]new[/COLOR] Oledbcommand(strSQL, myconnection)
cmd.ExecuteNonQuery()
[COLOR=blue]Next[/COLOR]

HTH
Regards ;)
 
Back
Top