以前是
cn.Open "Provider=SQLOLEDB;Data Source=lg;User ID=sa;Password=cycwxl;Initial Catalog=tjzxsk;Persist Security Info=True"
现在获得机器名为n
Dim n As String * 20
Dim pcName As String
GetComputerName n, 20
'MsgBox ncn的连接串datasource 部分该怎么写?
谢谢
cn.Open "Provider=SQLOLEDB;Data Source=lg;User ID=sa;Password=cycwxl;Initial Catalog=tjzxsk;Persist Security Info=True"
现在获得机器名为n
Dim n As String * 20
Dim pcName As String
GetComputerName n, 20
'MsgBox ncn的连接串datasource 部分该怎么写?
谢谢
strConn="Provider=SQLOLEDB;User ID=sa;Password=cycwxl;Initial Catalog=tjzxsk;Persist Security Info=True;Data Source=" & n自己把这个连接符debug.print出来嘛
问题解决了
参考:
Private Sub Command1_Click()
Dim Ret As Long
Dim buffer As String * 256
Dim ComputerName As String
Ret = GetComputerName(buffer, Len(buffer))
If Ret <> 0 Then
ComputerName = Left$(buffer, InStr(1, buffer, vbNullChar) - 1)
MsgBox "本机的机器名:" & ComputerName
End If
End Sub