SQL Server 如何与VB连接

2025-01-02 20:17:00
推荐回答(1个)
回答1:

VB引用MS ADO库,然后程序里面这么定义

Dim Conn As New ADODB.Connection
Dim oRs As New ADODB.Recordset
Dim StrSql As String

Conn.Open "DRIVER=SQL Server;SERVER=xxx.xxx.xxx.xxx;UID=sa;PWD=xxx;database=xxx;"
StrSql = "SQL语句"
oRs.Open StrSql, Conn, 1, 1
使用ors就行了