从存储过程中将数据插入到oracle中,该按钮点击后面的asp.net代码 [英] Insert data into oracle from stored procedure called from button clickin asp.net code behind

查看:59
本文介绍了从存储过程中将数据插入到oracle中,该按钮点击后面的asp.net代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在存储过程的帮助下在Employees(Empid,名字,姓氏,工资)表中插入数据。

我想要这个存储过程调用按钮点击后面的asp.net代码。

我正在使用oracle数据库。

如何创建存储过程并从中调用它我的代码背后。

谢谢

-Akshay

Hi,
I want to insert a data in the table Employees(Empid,first name,lastname,salary) with the help of stored procedure.
I want this stored proc called on button click from asp.net code behind.
I am using oracle database.
How can i go about in creating the stored proc and call it from my code behind.
Thanks
-Akshay

推荐答案

hi,

尝试使用Google.in Google,您可以获得所有答案。

这里有一些链接可以帮助您在Oracle中创建SP并从ASP.NET C#调用Oracle SP。



从C#调用Oracle SP



http://www.c-sharpcorner.com/UploadFile/john_charles/CallingOraclestoredproceduresfromMicrosoftdotNET06222007142805PM/Callin gOraclestoredproceduresfromMicrosoftdotNET.aspx [ ^ ]



http://stackoverflow.com/questions/3940587/calling-oracle-stored-procedure-from-c-net [ ^ ]



https://forums.oracle.com/thread/876314 [ ^ ]



http://srikanthtechnologies.com/articles/dotnet/oraclesp.html [ ^ ]



http://forums.asp.net/t/1192566.aspx/1 [ ^ ]



创建SP in oracle



http://www.techonthenet.com/oracle/procedures.php [ ^ ]



如何在oracle数据库中创建简单的存储过程 [ ^ ]

Try to use Google.in Google you can get all your answers.
Here are few links which will help you to create SP in Oracle and Call Oracle SP from ASP.NET C#.

Call Oracle SP from C#

http://www.c-sharpcorner.com/UploadFile/john_charles/CallingOraclestoredproceduresfromMicrosoftdotNET06222007142805PM/CallingOraclestoredproceduresfromMicrosoftdotNET.aspx[^]

http://stackoverflow.com/questions/3940587/calling-oracle-stored-procedure-from-c-net[^]

https://forums.oracle.com/thread/876314[^]

http://srikanthtechnologies.com/articles/dotnet/oraclesp.html[^]

http://forums.asp.net/t/1192566.aspx/1[^]

Creating SP IN oracle

http://www.techonthenet.com/oracle/procedures.php[^]

how to create simple stored procedure in oracle Database[^]


create package in oracle
create procedure in that package





创建或替换包装体SCHEMA.TEST_PKG

AS

程序TEST_PROC(VARCHAR2中的P_EMP_ID,VARCHAR2中的P_FISRT_NAME,VARCHAR2中的P_LAST_NAME,P_SALARY中的数字,P_TRANSACTION_STATUS OUT VARCHAR2)

AS

BEGIN

INSERT INTO EMPLOYEE(EMP_ID,FISRT_NAME,LAST_NAME,SALARY)

VALUES(P_EMP_ID,P_FISRT_NAME,P_LAST_NAME,P_SALARY);

P_TRANSACTION_STATUS:= 'SUCCESS';



END;





CREATE OR REPLACE PACKAGE BODY SCHEMA.TEST_PKG
AS
PROCEDURE TEST_PROC( P_EMP_ID IN VARCHAR2,P_FISRT_NAME IN VARCHAR2,P_LAST_NAME IN VARCHAR2,P_SALARY IN NUMBER, P_TRANSACTION_STATUS OUT VARCHAR2)
AS
BEGIN
INSERT INTO EMPLOYEE(EMP_ID,FISRT_NAME,LAST_NAME,SALARY)
VALUES (P_EMP_ID ,P_FISRT_NAME,P_LAST_NAME,P_SALARY);
P_TRANSACTION_STATUS := ‘SUCCESS’;

END;

In web code use microsoft enterprise libarry as ADO.net connectivity
and call above procedure from code behind







public string insert_data(string id, string name, string last_name, int salary)
    {
        string transactionstatus = string.Empty;
        if (db != null)
        {
            cmd = (OracleCommand)db.GetStoredProcCommand("TEST_PKG.TEST_PROC");
            cmd.Parameters.Add("P_EMP-ID", OracleType.VarChar, 2000).Value = id;
            cmd.Parameters.Add("P_FIRST_NAME",OracleType.VarChar, 2000).Value = name;
            cmd.Parameters.Add("P_LAST_NAME", OracleType.VarChar, 2000).Value = last_name;
            cmd.Parameters.Add("P_SALARY", OracleType.number, 2000).Value = salary;
            cmd.Parameters.Add("P_TRANSACTION_STATUS", OracleType.VarChar, 2000).Direction = ParameterDirection.Output;
            int i = db.ExecuteNonQuery(cmd);
            if (i <= 0)
            {
                transactionstatus = "FAIL";
            }
            return transactionstatus = cmd.Parameters["P_TRANSACTION_STATUS"].Value.ToString();
        }
        return transactionstatus;
    }


这篇关于从存储过程中将数据插入到oracle中,该按钮点击后面的asp.net代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆