VB.NET三种读SQL数据库命令实例一ADODB

前端之家收集整理的这篇文章主要介绍了VB.NET三种读SQL数据库命令实例一ADODB前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rst As New ADODB.Recordset
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=class.mdb"
cnn.Open()
Dim sql As String = "select * from class where classname like'%" + cclassname.Text + "%' or ccode like'%" + cclassname.Text + "%'"
rs.Open(sql,cnn,1,1)
If Not (rs.EOF And rs.BOF) Then
cclassname.Text = rs(1).Value.ToString() & "--" & rs(2).Value.ToString()
End If
Do While Not rs.EOF
cclassname.Items.Add(rs(1).Value.ToString() & "--" & rs(2).Value.ToString())
rs.MoveNext()
Loop
rs.Close()
rs = Nothing
cnn.Close()

猜你在找的VB相关文章