哪位大哥可以分享个listview控件+ADO操作数据库的范例啊?
现在正在学listview控件很多东东不明白,所以就来论坛里先求个范例模拟一下乱清楚脉络再举一反三自己写几个呢,望各位大哥帮下小弟,小弟学VB纯自学没师傅教可怜啊,谢谢
给你一段代码自己研究研究,SQL数据库就根据用到的字段自己建一个,遇到什么问题在提出来!
Private Sub comZB_Click()
If Combo3.Text <> Combo4.Text Then
List4.Clear
newcnn.Open cnstr
I = 0
Do While I < List3.ListCount
If List3.Selected(I) = True Then
SQL1 = "update 学生档案表 set 学号='" & Left(List3.list(I), 1) & Mid(Trim(Combo4.Text), 2, 1) & Mid(List3.list(I), 3, 4) & "',年级='" & Left(Trim(Combo4.Text), 1) & "班',班级='" & Mid(Trim(Combo4.Text), 2, 1) & "' WHERE 学号 ='" & Left(List3.list(I), 6) & "'"
newcnn.Execute SQL1
SQL2 = "update 余额表 set 学号='" & Left(List3.list(I), 1) & Mid(Trim(Combo4.Text), 2, 1) & Mid(List3.list(I), 3, 4) & "' WHERE 学号 ='" & Left(List3.list(I), 6) & "'"
newcnn.Execute SQL2
List3.RemoveItem I
Else
I = I + 1
End If
List3.Refresh
Loop
newcnn.Close
Adodc2.RecordSource = "select * from 学生档案表 where 年级 ='" & Left(Trim(Combo4.Text), 1) & "班' and 班级 ='" & Mid(Trim(Combo4.Text), 2, 1) & "' order by 学号"
Adodc2.Refresh
If Adodc2.Recordset.BOF = False Then Adodc2.Recordset.MoveFirst
For I = 0 To Adodc2.Recordset.RecordCount - 1
If Len(Trim(Adodc2.Recordset.Fields("学号"))) = 6 Then
List4.AddItem (Trim(Adodc2.Recordset("学号")) & "--" & Trim(Adodc2.Recordset.Fields("姓名")))
Adodc2.Recordset.MoveNext
End If
Next
If List4.ListCount > 0 Then List4.ListIndex = 0
Else
MsgBox ("请确定转至哪个班级!"), vbOKOnly, "提示"
Combo4.SetFocus
End If
End Sub