当前位置:编程学习 > C#/ASP.NET >>

如何将ListView中的所有数据读入数据库中

如何将ListView中的所有数据读入数据库中 --------------------编程问答-------------------- 怎么没人回答我这个问题,这个问题是太难还是太简单 --------------------编程问答-------------------- 不知道您是要怎么个读法哦,推荐您一行一行代码写吧.
ListView:LV
dim intI as integer
dim strsqlCommand as String="Insert Into XX(x,y,z) Values('"
for intI=0 to LV.ListItems.Count-1
  strsqlCommand+=LV.ListItems.Item(intI).Text+"','"+LV.ListItems.Item(intI).SubItems(1).Text+"','"+LV.ListItems.Item(intI).SubItems(1).Text+"'"
next
然后再将strsqlCommand作为sqlclient.sqlCommand的CommandText的属性,最后调用sqlCommand的ExecuteNonquery方法,前提是您有一个sqlConnection存在并且sqlCommand.Connection=sqlConnection
其实我推荐您使用DataGridView控件 --------------------编程问答-------------------- 循环遍历就可以了 --------------------编程问答-------------------- 好像没那么简单,呵呵. --------------------编程问答-------------------- 我也想了解,谢谢LZ.
补充:.NET技术 ,  .NET Framework
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,