将数据插入oracle数据库 [英] Insert data into oracle database
本文介绍了将数据插入oracle数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将数据插入到oracle数据库表中bt我得到错误,第1行第7列错误的数字或类型的参数调用程序名称
i已经检查了参数和数据类型的数量bt仍然不起作用请建议一下
以下是我的代码
提前感谢
我尝试过:
Im trying to insert the Data into oracle database table bt im getting error that Line 1 column 7 Wrong number or type of argument in call to procedure name
i have checked the number of parameters and data type bt still its not working please suggest sumthing
below is my code
thanks in advance
What I have tried:
public int InsertDocuments(int DocId, string DocName, string DocPath)
{
string oradb = GetConnectionString_Oracle();
OraConn = new OracleConnection();
OraConn.ConnectionString = oradb;
//OraConn = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleConnString"].ToString());
int i = 0;
try
{
OracleCommand command = new OracleCommand("AddUpdateDocuments", OraConn);
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = 3600;
command.Parameters.Add("DocId", OracleType.Number).Value = DocId ;
command.Parameters.Add("DocName", OracleType.VarChar).Value = DocName;
command.Parameters.Add("Docpath", OracleType.VarChar).Value = DocPath;
OraConn.Open();
i = command.ExecuteNonQuery();
OraConn.Close();
return 1;
}
catch (SqlException ex)
{
return 0;
}
}
}
我的商店程序
my store procedure
CREATE OR REPLACE PROCEDURE AddUpdateDocuments
(DocId in Number , DocName IN varchar, LossType IN VARCHAR2)
AS
amatched number;
MaxDocId number;
BEGIN
SELECT COUNT(*) INTO amatched FROM LCLDocMst
WHERE DocName = DocName;
IF amatched !=0 THEN
UPDATE LCLDocMst
SET DocName = DocName
WHERE DocId = DocId;
ELSE
select Max(DOCID) INTO MaxDocId FROM LCLDocMst;
INSERT INTO LCLDocMst(DocId, DocName, LossType, Docpath)
VALUES (MaxDocId, DocName, LossType, '');
END IF;
END AddUpdateDocuments;
/
推荐答案
嗯,这很容易。 :)
您的程序有参数叫DocId
,DocName
和LossType
。
您的C#代码传递的参数叫DocId
,DocName
,Docpath
。
从C#传递的参数需要与程序的参数匹配。
Well, that's easy. :)
Your procedure has parameters calledDocId
,DocName
, andLossType
.
Your C# code is passing parameters calledDocId
,DocName
, andDocpath
.
The parameters you pass from C# need to match the parameters of the procedure.
这篇关于将数据插入oracle数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文