VB6.0+SQL Server+ADODB

前端之家收集整理的这篇文章主要介绍了VB6.0+SQL Server+ADODB前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

直连,我个人喜欢这种方式。1.在工程里需要引用ADO的Libary,具体就得看ADO的版本了,在前面打钩就可以了。2.Dim sqlcon As New ADODB.ConnectionDim sqlrec As ADODB.RecordsetdbUser = "." dbPassword = ""dbName = "Northwind"dbServer = "127.0.0.1"sqlcon.Open "Provider=sqlOLEDB.1; User ID=" & dbUser & ";Password=" & dbPassword & ";Initial Catalog=" & dbName & "; Data Source=" & dbServersqlQuery = "Select * from employees ORDER BY FirstName ASC"sqlcon.Execute (sqlQuery) '指执行,不返回结果sqlrec.Open "select * from titles where title like '%h'",sqlcon ADOGrid1.ShowData sqlrec

猜你在找的VB相关文章