我这样写的,程序在我机器上能运行,但是源文件到别人机器上不能运行Public Function getstrs(Optional strQue As String) As Object
Dim cnst As ADODB.Connection
Dim Conn As String
Conn = "UID=tll;PWD=tll;DRIVER={Microsoft ODBC for Oracle};" _
& "SERVER=tll;"
Set cnst = New ADODB.Connection With cnst
.ConnectionString = Conn
.CursorLocation = adUseClient
.Open
End With
Dim rs As New ADODB.Recordset
If Len(strQue) > 0 Then
Set rs = New ADODB.Recordset
Else
Exit Function
End If
rs.CursorLocation = adUseClient
rs.Open strQue, cnst, adOpenDynamic, adLockOptimistic
Set getstrs = rs
Exit Function
End Function
Dim cnst As ADODB.Connection
Dim Conn As String
Conn = "UID=tll;PWD=tll;DRIVER={Microsoft ODBC for Oracle};" _
& "SERVER=tll;"
Set cnst = New ADODB.Connection With cnst
.ConnectionString = Conn
.CursorLocation = adUseClient
.Open
End With
Dim rs As New ADODB.Recordset
If Len(strQue) > 0 Then
Set rs = New ADODB.Recordset
Else
Exit Function
End If
rs.CursorLocation = adUseClient
rs.Open strQue, cnst, adOpenDynamic, adLockOptimistic
Set getstrs = rs
Exit Function
End Function
"Provider=MSDAORA.1;Password=tll;User ID=tll;Data Source=tll;Persist Security Info=True"
如果你用odbc的话,在别人电脑上必须配相同名字的ODBC
在你的程序里须在别人电脑配一个名为tll的odbc 名字!