0

我把程序写成

CREATE OR REPLACE PROCEDURE proc_ss(cName IN PayRoll.Name%VARCHAR2(50)   
)
IS
BEGIN 
 insert into employees(Name) values(cName);
END;

它通过 sql plus 执行时出现了一些编译错误。

我用于访问此过程的 c# 代码是

OdbcCommand cmdupd = new OdbcCommand("{call proc_ss(?)}", con);    
            cmdupd.CommandType = CommandType.StoredProcedure;
            cmdupd.Parameters.Add("Name", OdbcType.VarChar, 50).Value = Name;           
            cmdupd.ExecuteNonQuery();
            cmdupd.Dispose();

在运行上述查询时,我收到错误

System.data.odbcexception as:

ERROR [NA000] [Microsoft][ODBC driver for Oracle][Oracle]ORA-20003:
ERROR [42000] [Microsoft][ODBC driver for Oracle]Syntax error or access violation

Stack Trace as:

   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
   at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
   at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
   at payroll.BusinessAccessLayer.updating(Int32 id, String Name, String Phone, String Email, String Designation, String LevelID, String Username, String Password) in e:\payrollmanagement-oracle\source\Payroll\App_Code\BusinessAccessLayer.cs:line 103
   at employees.gridEmployees_RowUpdating(Object sender, GridViewUpdateEventArgs e) in e:\payrollmanagement-oracle\source\Payroll\employees.aspx.cs:line 118
   at System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e)
   at System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation)
   at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
   at System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e)
   at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

我不知道我被困在哪里......!

等待您的宝贵回复和意见..

4

1 回答 1

1

command Name用 proc_ss调整

OdbcCommand cmdupd = new OdbcCommand("{ CALL proc_ss(?) }", con);  

你也调整你的参数

 cmdupd.Parameters.Add("@cName", OdbcType.VarChar, 50).Value = Name;   
于 2012-09-18T14:48:25.237 回答