listviewname.selectitem[0].subitem[i].text
创新互联主要从事网站设计、成都网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务横峰,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108
listviewname就是控件名字
i枚举每行的每个项,如果有几个不知道就用listviewname.selectitem[0].subitem.count求
一个可以设置主键,删除唯一的主键,如delete
table
where
主键='"+键值+"',这样每一行都有区分
还可以和控件绑定,如datagrid,可以用datagrid.currentrow来获的当前行
第三种:可以用游标Enumerator,IEnumberator
objenum=dataview.GetEnumerator(),
row=(DataRowView)
objEnum.Current;
参考一下下面这段代码:
Imports System.Data.OleDb
Public Class Form1
Dim SqlCOM As OleDbConnection
Dim SqlUse As OleDbDataAdapter
Dim Dt As DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'连接数据库
SqlCOM = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\LP\Documents\Database1.accdb")
'执行数据命令获取表
SqlUse = New OleDbDataAdapter("SELECT * FROM 表1", SqlCOM)
Dt = New DataSet
SqlUse.Fill(Dt) '放入dataset中
Catch
MsgBox(Err.Description, 48)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
DataGridView1.DataSource = Dt.Tables(0).DefaultView 'DVG与DADASET同步数据显示
Catch
MsgBox(Err.Description, 32)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim ass As New OleDbCommandBuilder(SqlUse) '关联DataSet和数据库的操作(更新)
SqlUse.UpdateCommand = ass.GetUpdateCommand() '执行更新所需的 OleDbCommand 对象
SqlUse.Update(Dt.Tables(0)) '执行OleDbDataAdapter的Update更新数据库
Catch
MsgBox(Err.Description, 32)
Finally
MsgBox("更新成功", 64)
End Try
End Sub
End Class