protected void Button1_Click1(object sender, EventArgs e)
{
using (OracleConnection conn = new OracleConnection())
{
conn.ConnectionString = connectionstring;
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into PFC.Trial(FAME)VALUES(@FAME)";
cmd.Parameters.Add(new OracleParameter("@FAME", TextBox1.Text));
cmd.ExecuteNonQuery();
}
}
}
}
错误在这里
错误在最后一行
cmd.executenonquery();
答案 0 :(得分:1)
您需要在设置参数时删除符号,也应该是冒号而不是@ for Oracle:
using (OracleConnection conn = new OracleConnection())
{
conn.ConnectionString = connectionstring;
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into PFC.Trial(FAME)VALUES(:FAME)";
cmd.Parameters.Add(new OracleParameter("FAME", TextBox1.Text));
cmd.ExecuteNonQuery();
}