• 主页
  • Oracle 基础和管理
  • Oracle 高级技术
  • Oracle 认证与考试

vb连接服务器端oracle 数据库求救!

ruralclimber 2005-03-20 06:42:00
在一台服务器的linux 平台下装上oracle 9.2.0.1,并用dbca创建了一数据库。在客户机上安装了oracle 客户端软件。现在要在此客户机上用vb开发基于该数据库的应用程序(比如对数据库的查询,插入等),请问现在如何使vb连上服务器机上的oracle 数据库呀? 用什么控件? 是ADO最好吗?该怎样填加代码?

谢谢!
...全文
30 点赞 收藏 1
写回复
1 条回复
flyingcode 2005年03月20日
//////////////////试试看咯//////////////////////

Option Explicit

Public strConn As String
Public oracleConn As New ADODB.Connection

Public Function OpenOracleDB() As Boolean
On Error GoTo proc_error
oracleConn.Open strConn
If oracleConn.State = 1 Then
OpenOracleDB = True
Else
OpenOracleDB = False
End If
proc_exit:
Exit Function
proc_error:

GoTo proc_exit
MsgBox "OpenOracleDB()" & Err.Description
End Function


Public Function CloseOracleDB() As Boolean
On Error GoTo proc_error
If oracleConn.State = 0 Then CloseOracleDB = True
oracleConn.Close
If oracleConn.State = 0 Then
CloseOracleDB = True
Else
CloseOracleDB = False
End If
proc_exit:
Exit Function
proc_error:

GoTo proc_exit
MsgBox "CloseOracleDB()" & Err.Description
End Function

Private Sub Class_Initialize()
strConn = "Provider=MSDAORA.1;User ID=hr;PassWord=111;Data Source=hgf;Persist Security Info=False;"
End Sub

Private Sub Class_Terminate()
CloseOracleDB
End Sub
////////////////
Option Explicit

Private Sub Command1_Click()
Dim db As COracleDB
Set db = New COracleDB
db.OpenOracleDB
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select * from jobs", db.oracleConn, adOpenKeyset, adLockReadOnly
Dim i As Integer
i = 1
Me.MSFlexGrid1.Rows = Me.MSFlexGrid1.Rows + rs.RecordCount - 1
Do Until rs.EOF
Me.MSFlexGrid1.TextMatrix(i, 1) = rs.Fields("job_id") & ""
Me.MSFlexGrid1.TextMatrix(i, 2) = rs.Fields("job_title") & ""
Me.MSFlexGrid1.TextMatrix(i, 3) = rs.Fields("min_salary") & ""
Me.MSFlexGrid1.TextMatrix(i, 4) = rs.Fields("max_salary") & ""
rs.MoveNext
i = i + 1
Loop
End Sub
回复 点赞
发动态
发帖子
Oracle
创建于2007-09-28

6409

社区成员

5.4w+

社区内容

Oracle开发相关技术讨论
社区公告
暂无公告