Hi All,
I am trying to call an oracle stored procedure to insert data from HTML
form. Here is the code:
Could you help me and let me know why it fails after opening the
connection.
Stored procedure accepts 3 input parameters -2 varchars and 1 number.
--------Code------------------------------------------------------
<HTML>
<HEAD>
<link rel="stylesheet" href="default.css" type="text/css">
</HEAD>
<BODY>
<%
'*******************************************************************************
'* Name: GetDBConnection
'* Description:
'* Returns an open ADO Connection object.
'*******************************************************************************
Private Function GetDBConnection
Const cConnection = "SERVER=<servername>;driver={Microsoft ODBC for
Oracle};UID="uid";PWD="pwd";"
Dim objConnection
'* Create the connection object
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.ConnectionString = cConnection
objConnection.CursorLocation = 3 '* adUseClient
objConnection.Open
'* Return the new connection back to the calling routine
Set GetDBConnection = objConnection
End Function
%>
<H2>Add </H2>
<p><a href="default.htm">Home</a></p>
<FORM method=post action=add.asp name=frm>
<B>Add Service<BR></B>
<p>
Customer Id :<INPUT id="txtcustno" name="txtcustno" TYPE="TEXT"
value="">
<p>Service :<INPUT id="txtsub" name="txtsub" TYPE="TEXT" value="" >
<p>Save :<INPUT id="txtsave" name="txtsave" value="" >
<%
Dim objServicesCommand '* Command object to execute Stored Procedure
Dim lngRecs
vlogin = cstr(Request.Form("txtcustno"))
vsub = cstr(Request.Form("txtsub"))
vsave = clng(Request.Form("txtsave"))
'* Set up the command object to call the Stored Procedure
Set objServicesCommand = Server.CreateObject("ADODB.Command")
objServicesCommand.ActiveConnection = GetDBConnection()
Response.Write "Connected"
objServicesCommand.CommandType = adCmdStoredProc
objServicesCommand.CommandText ="TEST_PACKAGE.TEST_ADD"
objServicesCommand.Parameters.Refresh
objServicesCommand.Parameters(0).Direction = adParamInput
objServicesCommand.Parameters(1).Direction = adParamInput
objServicesCommand.Parameters(2).Direction = adParamInput
'* Set Parameter values
objServicesCommand.Parameters(0).Value = vlogin
objServicesCommand.Parameters(1).Value = vsub
objServicesCommand.Parameters(2).Value = vsave
objServicesCommand.Parameters(0).Size=len(vlogin)
objServicesCommand.Parameters(1).Size=len(vsub)
'* Execute the Stored Procedure.
'objServicesCommand.Execute lngRecs, ,adExecuteNoRecords
objServicesCommand.Execute
Response.Write "New Service Addded"
Set objServicesCommand = Nothing
%>
<INPUT type=submit value="ADD SERVICE" id=submit1 name=submit1>
</p>
</FORM>
<P></P>
</BODY>
</HTML>
----------------end Code--------------------------
Thanks all.