vb 谁告诉我这个代码的意思

来源:百度知道 编辑:UC知道 时间:2024/09/20 16:58:04
Public Sub DatabaseOpen()
Dim ConnectString As String
Set conn = New ADODB.Connection
ConnectString = "Provider=SQLOLEDB.1;Persist Security Info=False;User_ID=sa;PWD="";Initial Catalog=Student;Data Source=Student"
conn.CursorLocation = adUseClient
cnnn.Open ConnectString
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
End Sub
可是为什么我连接不上数据库呢

这是个连接SQL数据库的代码
Public Sub DatabaseOpen() 声明共有过程 DatabaseOpen
Dim ConnectString As String 设置ConnectString为字符型
Set conn = New ADODB.Connection 设置conn为新的连接实例
ConnectString = "Provider=SQLOLEDB.1;Persist Security Info=False;User_ID=sa;PWD="";Initial Catalog=Student;Data Source=Student" 把链接SQL的参数赋值到ConnectString字符上
conn.CursorLocation = adUseClient 定义ADO连接是用客户端的游标
cnnn.Open ConnectString 打开数据库
Set cmd = New ADODB.Command 设置CMD为数据源执行的命令
cmd.ActiveConnection = conn 设置CONN打开的连接与 Command 对象关联

VISUAL BISCAL国家计算机二级考试中的一项。

全称叫visual basic 是一种程序设计软件的名称。

连接sql server数据库student

全局定义的字程序 打开数据库
定义一个 字符串变量
开始连接
连接地址
中间只是赋予处理过程
活动连接
程序完成

这是链接MSSQL 数据库的代码?