我想建一个后缀名为vbs的文件,当点运行该文件是能执行下面的sql语句:
select name from accts where acct="100001"
并能显示出执行结果(用msgbox).
数据库为Oracle数据库,数据库名:mydatabase,用户名:myuserid,密码:mypassword.
怎样实现?请指导一下。最好给出代码,谢谢!
select name from accts where acct="100001"
并能显示出执行结果(用msgbox).
数据库为Oracle数据库,数据库名:mydatabase,用户名:myuserid,密码:mypassword.
怎样实现?请指导一下。最好给出代码,谢谢!
是否有帮助
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;"
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Open strConnect
strResults = adoConnection.execute(strSQL)
msgbox strResults
adoConnection.Close 保存在test.vbs文件中,当我运行此文件是,报错:
Microsoft VBScript 编译器错误 错误 '800a03ea' 这是咋回事啊 ?
& "Data Source=mydatabase;" _
& "User ID=myuserid;" _
& "Password=mypassword;"