我想將數據插入到表下方未能參數值從字符串轉換爲使用像<code>Storedprocedure.</code></p> <p>我已經寫代碼十進制錯誤
OracleConnection ObjPriCon = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OracleConn"].ToString());
ObjPriCon.Open();
string spquery = "xxcus.pn_insert_grid_agreeement";
OracleCommand cmd = new OracleCommand(spquery, ObjPriCon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("Mkey", OracleType.Number).Value = e.Record["Mkey"];
cmd.Parameters.Add("GrdType", OracleType.VarChar).Value = e.Record["grd_type"];
cmd.Parameters.Add("firstname", OracleType.VarChar).Value = e.Record["f_name"];
cmd.Parameters.Add("lastname", OracleType.VarChar).Value = e.Record["l_name"];
cmd.Parameters.Add("contactdet", OracleType.Number).Value = e.Record["cont_det"];
cmd.Parameters.Add("pancardDet", OracleType.VarChar).Value = e.Record["pancard_det"];
cmd.Parameters.Add("trantype", OracleType.VarChar).Value = "GDS";
cmd.Parameters.Add("createdby", OracleType.Number).Value = Request.QueryString["userid"].ToString();
cmd.Parameters.Add("creationdate", OracleType.DateTime).Value = DateTime.Now.ToString("dd/MM/yyyy");
cmd.Parameters.Add("lastUpdateDate", OracleType.DateTime).Value = DateTime.Now.ToString("dd/MM/yyyy");
cmd.Parameters.Add("lastUpdatedBy", OracleType.Number).Value = Request.QueryString["userid"].ToString();
cmd.Parameters.Add("deleteflag", OracleType.Char).Value = "N";
cmd.ExecuteNonQuery();
ObjPriCon.Close();
但在cmd.ExecuteNonQuery()
我得到錯誤的
無法將參數值從字符串轉換爲小數。
我不明白錯誤所在
也看到我的SP結構
CREATE OR REPLACE PROCEDURE XXCUS.pn_insert_grid_agreeement (
mkey NUMBER,
GrdType VARCHAR2,
firstname VARCHAR2,
lastname VARCHAR2,
contactdet NUMBER,
pancardDet VARCHAR2,
trantype VARCHAR2,
createdby NUMBER,
creationdate DATE,
lastUpdateDate DATE,
lastUpdatedBy NUMBER,
deleteflag CHAR
)
IS
BEGIN
INSERT INTO xxcus.xxacl_pn_grid_agreement
(MKEY, grd_type, f_name, l_name, cont_det, pancard_det, tran_type,
created_by, creation_date, last_update_date,
last_updated_by, delete_flag
)
VALUES (mkey, GrdType, firstname,lastname, contactdet,pancardDet, trantype,
createdby, creationdate, lastUpdateDate,
lastUpdatedBy, deleteflag
);
END;
請提示這裏有什麼問題
UDPATE
Mkey
是自動遞增列。
你嘗試creationdate和LASTUPDATEDATE不添加字符串格式? –
@mwisnicki:對不起,你沒有?你的意思是我加了'hh:mm:ss'嗎? – BNN
只設置DateTime.Now.Date。並告訴我數據庫中數字值的精確度是多少? –