首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vbs文件怎样能实现连接Oracle的功能?该怎么处理

2012-01-19 
vbs文件怎样能实现连接Oracle的功能?我想建一个后缀名为vbs的文件,当点运行该文件是能执行下面的sql语句:s

vbs文件怎样能实现连接Oracle的功能?
我想建一个后缀名为vbs的文件,当点运行该文件是能执行下面的sql语句:
select name from accts where acct="100001"
并能显示出执行结果(用msgbox).
数据库为Oracle数据库,数据库名:mydatabase,用户名:myuserid,密码:mypassword.
怎样实现?请指导一下。最好给出代码,谢谢!

[解决办法]
createobject
其他和vb一样
[解决办法]
看一下这里http://hi.baidu.com/379415273/blog/item/a8f778faf31f1d62024f5695.html 
是否有帮助 
 

[解决办法]
1. Open a new project in Visual Basic and add a Reference to the Microsoft ActiveX Data Objects library. 
2. Place the following controls on the form: 
Control Name Text/Caption

Button cmdCheck Check
Button cmdSend Send
Text Box txtInput
Label lblInput Input:
 
3. From the Tools menu, choose Options, Click the "Default Full Module View" option, and then click OK. This allows you to view all of the code for this project. 
4. Paste the following code into your code window: 
Option Explicit
Dim Cn As ADODB.Connection
Dim CPw1 As ADODB.Command
Dim CPw2 As ADODB.Command
Dim Rs As ADODB.Recordset
Dim Conn As String
Dim QSQL As String

Private Sub cmdCheck_Click()

CPw1(0) = Val(txtInput.Text)

Set Rs = CPw1.Execute

MsgBox "Item_Number = " & Rs(0) & ". Depot_Number = " & Rs(1) & "."

Rs.Close

End Sub

Private Sub cmdSend_Click()

CPw2(0) = Val(txtInput.Text)

CPw2.Execute

MsgBox "Return value from stored procedure is " & CPw2(1) & "."

End Sub

Private Sub Form_Load()

'You will need to replace the "*" with the appropriate values.
Conn = "UID=*****;PWD=****;DRIVER={Microsoft ODBC for Oracle};" _
& "SERVER=*****;"

Set Cn = New ADODB.Connection

With Cn
.ConnectionString = Conn
.CursorLocation = adUseClient
.Open
End With

QSQL = "Select Item_Number, Depot_Number From adooracle Where " _
& "item_number = ?"

Set CPw1 = New ADODB.Command

With CPw1
.ActiveConnection = Cn
.CommandText = QSQL
.CommandType = adCmdText
.Parameters.Append .CreateParameter(, adInteger, adParamInput)
End With

QSQL = "adoinsert"

Set CPw2 = New ADODB.Command

With CPw2
.ActiveConnection = Cn
.CommandText = QSQL
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter(, adInteger, adParamInput)
.Parameters.Append .CreateParameter(, adDouble, adParamOutput)
End With

End Sub

Private Sub Form_Unload(Cancel As Integer)

Cn.Close
Set Cn = Nothing
Set CPw1 = Nothing
Set CPw2 = Nothing

End Sub
 

[解决办法]
strConnect = = "Provider=MSDAORA;" _ 
& "Data Source=mydatabase;" _ 
& "User ID=myuserid;" _ 
& "Password=mypassword;" 

热点排行