简体   繁体   English

将参数从vbscript传递到oracle存储过程

[英]passing parameter from vbscript to oracle stored procedure

Dim strConnection, conn, rs, strSQL, objCommand, param strConnection = "Driver={Oracle ODBC Driver};Data Source=DSNNAME;User Id=Username;Password=password;" “ Dim strConnection,conn,rs,strSQL,objCommand,param strConnection =”驱动程序= {Oracle ODBC驱动程序};数据源= DSNNAME;用户ID =用户名;密码=密码;“ Set conn = CreateObject("ADODB.Connection") conn.Open strConnection 设置conn = CreateObject(“ ADODB.Connection”)conn.Open strConnection

Dim cmdInsert As ADODB.Command
Set cmdInsert = New ADODB.Command
cmdInsert.ActiveConnection = conn
cmdInsert.CommandText = "sp_ins_test"
cmdInsert.CommandType = 4
cmdInsert.Parameters.Refresh

Set param = cmdInsert.Parameters
param.Append cmdInsert.CreateParameter("v_BG_EI_DEFECT_TYPE", 200, 1, 100, "abc")
param.Append cmdInsert.CreateParameter("v_BG_EI_APP_ID", 3, 1, 8, 1) 
param.Append cmdInsert.CreateParameter("v_BG_DETECTION_DATE", 133, 1, 100, 8/6/2010)

cmdInsert.Execute cmdInsert.Execute

It is throwing error as Character to number conversion error but i am passing int the code is 3 for integer(but the datatype is number in database) and also passing date 它以字符到数字转换错误的形式抛出错误,但我将int传递给整数的代码是3(但数据类型是数据库中的数字)并且还传递了日期

Please tell me how to pass parameters to date and number datatype in oracle.. 请告诉我如何在oracle中将参数传递给date和number数据类型。

I can see at least these problems: 我至少可以看到以下问题:

  • If the script really shall be VBScript, then As ADODB.Command and New ADODB.Command are illegal; 如果脚本确实是VBScript,则As ADODB.CommandNew ADODB.Command是非法的; these are valid in VB only. 这些仅在VB中有效。 Use CreateObject instead. 请改用CreateObject
  • 8/6/2010 is not a valid date literal, it is an integer expression evaluating to a very small value (almost 0); 8/6/2010不是有效的日期文字,它是一个整数表达式,计算8/6/2010值非常小(几乎为0); use #8/6/2010# instead. 请改用#8/6/2010#

I hope this helps. 我希望这有帮助。

您正在将空strings传递到参数中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM