C#向Oracle表中插入数据
publicboolInsertRow(string[]paramList){OracleConnectionconn=newOracleConnection(oracl...
public bool InsertRow(string[] paramList)
{
OracleConnection conn = new OracleConnection(oracleConString);
var SQL = "insert into t_con_auditform (A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A26) values(@A2,@A3,@A4,@A5,@A6,@A7,@A8,@A9,@A10,@A11,@A26)";
//var newSQL = string.Format(SQL, ID, System.DateTime.Now.ToShortDateString());
OracleCommand adapter = new OracleCommand(SQL, conn);
try
{
conn.Open();
adapter.CommandType = CommandType.StoredProcedure;
//todo:把传入的参数集合 赋值给相应的参数
adapter.Parameters.AddWithValue("@A2", paramList[0]);
adapter.Parameters.AddWithValue("@A3", paramList[1]);
adapter.Parameters.AddWithValue("@A4", paramList[2]);
adapter.Parameters.AddWithValue("@A5", paramList[3]);
adapter.Parameters.AddWithValue("@A6", paramList[4]);
adapter.Parameters.AddWithValue("@A7", paramList[5]);
adapter.Parameters.AddWithValue("@A8", paramList[6]);
adapter.Parameters.AddWithValue("@A9", paramList[7]);
adapter.Parameters.AddWithValue("@A10", paramList[8]);
adapter.Parameters.AddWithValue("@A11", paramList[9]);
adapter.Parameters.AddWithValue("@A26", paramList[10]);
adapter.Parameters.AddRange(paramList);
adapter.CommandText = SQL;
adapter.ExecuteNonQuery();
return true;
}
catch
{
return false;
}
finally
{
adapter.Dispose();
conn.Close();
}
}
在表中老是显示不出来插入的数据 展开
{
OracleConnection conn = new OracleConnection(oracleConString);
var SQL = "insert into t_con_auditform (A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A26) values(@A2,@A3,@A4,@A5,@A6,@A7,@A8,@A9,@A10,@A11,@A26)";
//var newSQL = string.Format(SQL, ID, System.DateTime.Now.ToShortDateString());
OracleCommand adapter = new OracleCommand(SQL, conn);
try
{
conn.Open();
adapter.CommandType = CommandType.StoredProcedure;
//todo:把传入的参数集合 赋值给相应的参数
adapter.Parameters.AddWithValue("@A2", paramList[0]);
adapter.Parameters.AddWithValue("@A3", paramList[1]);
adapter.Parameters.AddWithValue("@A4", paramList[2]);
adapter.Parameters.AddWithValue("@A5", paramList[3]);
adapter.Parameters.AddWithValue("@A6", paramList[4]);
adapter.Parameters.AddWithValue("@A7", paramList[5]);
adapter.Parameters.AddWithValue("@A8", paramList[6]);
adapter.Parameters.AddWithValue("@A9", paramList[7]);
adapter.Parameters.AddWithValue("@A10", paramList[8]);
adapter.Parameters.AddWithValue("@A11", paramList[9]);
adapter.Parameters.AddWithValue("@A26", paramList[10]);
adapter.Parameters.AddRange(paramList);
adapter.CommandText = SQL;
adapter.ExecuteNonQuery();
return true;
}
catch
{
return false;
}
finally
{
adapter.Dispose();
conn.Close();
}
}
在表中老是显示不出来插入的数据 展开
2个回答
展开全部
1. 有错误提示吗?
2. var SQL = "insert into t_con_auditform (A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A26) values(@A2,@A3,@A4,@A5,@A6,@A7,@A8,@A9,@A10,@A11,@A26)";
你这是sqlserver的帆禅培写法吧?Oracle应该这么写的:
var SQL = "insert into t_con_auditform (A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A26) values(:A2,:A3,:A4,:A5,:A6,:A7,:A8,:A9,:A10,:A11,:A26)";
3. adapter.CommandType = CommandType.StoredProcedure;
应袭宽该是
adapter.CommandType = CommandType.Text;
4. adapter.Parameters.AddWithValue("@A2", paramList[0]);
应该是:态唯
adapter.Parameters.AddWithValue("A2", paramList[0]);
2. var SQL = "insert into t_con_auditform (A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A26) values(@A2,@A3,@A4,@A5,@A6,@A7,@A8,@A9,@A10,@A11,@A26)";
你这是sqlserver的帆禅培写法吧?Oracle应该这么写的:
var SQL = "insert into t_con_auditform (A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A26) values(:A2,:A3,:A4,:A5,:A6,:A7,:A8,:A9,:A10,:A11,:A26)";
3. adapter.CommandType = CommandType.StoredProcedure;
应袭宽该是
adapter.CommandType = CommandType.Text;
4. adapter.Parameters.AddWithValue("@A2", paramList[0]);
应该是:态唯
adapter.Parameters.AddWithValue("A2", paramList[0]);
更多追问追答
追问
还想问你个问题,就是那个WEB单选信息怎么在Oracle表中显示?我是如下操作的:
protected string YesInvolFinal_CheckedChanged(object sender, EventArgs e)
{
if (YesInvolFinal.Checked)
{
return YesInvolFinal.Text;
}
else
{
return NoInvolFinal.Text;
}
追答
用0/1表示吧
protected string YesInvolFinal_CheckedChanged(object sender, EventArgs e)
{
if (YesInvolFinal.Checked)
{
return "1";
}
else
{
return "0";
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询