直连,我个人喜欢这种方式。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
原文链接:https://www.f2er.com/vb/262196.html