局域网的数据库应用编程

acup 2000-10-19 10:44:00
请问如何在本地建立远程(或局域网)的数据源连接,
需要检索数据库服务器名称和API函数,但我找不到相关资料
望高手帮忙
...全文
344 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
czh918 2000-10-20
  • 打赏
  • 举报
回复
office2000下有ado的资料
lou_df 2000-10-19
  • 打赏
  • 举报
回复
ODBC,ADO
acup 2000-10-19
  • 打赏
  • 举报
回复
我的意思是:一个新的环境在安装应用程序前,并没有建立应用程序所需的数据源,
在安装过程中,要通过搜索数据库服务器,由程序建立数据源,这个过程如何实现?
  • 打赏
  • 举报
回复
以下是ADO建立数据源和访问数据库的例子,也许对你有用!
<<<<<<<<<<<<<<<<<<<<<<<<code>>>>>>>>>>>>>>>>>>>>>>>>>
Private mvarLastDSN As String
Private mvarConnectResult As Boolean

Public Function GetConnectDSN(ByVal DSN As String) As String
Dim C As DataLinks
Dim d As ADODB.Connection
Set C = New DataLinks
Set d = New ADODB.Connection
d.ConnectionString = DSN
If C.PromptEdit(d) = True Then
GetConnectDSN = d.ConnectionString
mvarLastDSN = d.ConnectionString
mvarConnectResult = True
Else
mvarConnectResult = False
GetConnectDSN = ""
End If
Set d = Nothing
End Function


Public Function ConnectDB(ByVal DSN As String) As String
If DSN <> "" Then
ConnectDB = GetConnectDSN(DSN)
Else

ConnectDB = GetConnectDSN("")
Dim i As Integer
End If
End Function

Public Property Get ConnectResult() As Boolean
ConnectResult = mvarConnectResult
End Property

Public Function OpenConnection(DSN As String) As String
Set CONN = New ADODB.Connection
CONN.ConnectionString = DSN
CONN.CursorLocation = adUseClient
On Error GoTo ErrHandle
CONN.Open
OpenConnection = DSN
Exit Function
ErrHandle:
DSN = ""
DSN = ConnectDB(DSN)
CONN.ConnectionString = DSN
CONN.CursorLocation = adUseClient
CONN.Open
OpenConnection = DSN
End Function


'////////////////////////////////////////////////////////
'//FuctionName: ExecuteSQL
'//功能:执行SQL语句
'//IN: SQLStatement(string)
'//OUT: None
'////////////////////////////////////////////////////////
Public Function ExecuteSQL(SQLStatement As String) As Boolean
Dim comm As ADODB.COMMAND
Set comm = New ADODB.COMMAND
comm.ActiveConnection = CONN
comm.CommandText = SQLStatement
comm.CommandType = adCmdText
comm.Execute
End Function


'////////////////////////////////////////////////////////
'//FunctionName: ExecuteTSQL
'//功能:执行SQL语句打开一个表
'//IN: SQLStatement
'//OUT: rsTable
'////////////////////////////////////////////////////////
Public Function ExecuteTSQL(rsTable As ADODB.Recordset, SQLStatement As String) As Boolean
ExecuteTSQL = False
rsTable.LockType = adLockOptimistic
rsTable.CursorType = adOpenKeyset


On Error GoTo ErrHandle
rsTable.Open SQLStatement, CONN, , , adCmdText
'MsgBox rsTable.RecordCount
ExecuteTSQL = True
Exit Function

ErrHandle:
If Err.Number = -2147467259 Then
MsgBox Err.Number & "====" & Err.Description
Exit Function
End If
End Function




1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧