vb连接局域网数据库问题
代码如下,总是提示这一具有问题:cnn.Open "Provider=SQLOLEDB.1;Persist Security Info=true;User ID=sa;Password=aifei;Data Source=192.168.1.10"请老师指教,谢谢
Sub AddData()
SourceM = "\\米兰-pc\d\数据库\MSSQL\Data\db_SCGL_Data.MDF"
SourceL = "\\米兰-pc\d\数据库\MSSQL\Data\db_SCGL_Log.LDF"
Set con = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB.1;Persist Security Info=true;User ID=sa;Password=aifei;Data Source=192.168.1.10"
On Error Resume Next
Set rs = New ADODB.Recordset
str = "EXEC sp_attach_db @dbname = N'db_SCGL', @filename1 = N'" + SourceM + "', @filename2 = N'" + SourceL + "'"
Set rs = con.Execute(str)
Dim cn As New ADODB.Connection
cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=aifei;Initial Catalog=db_SCGL"
If Err.Number = -2147217900 Then '捕捉错误号
Frm_mm.Show
Unload Me
End If
End Sub