有很多与这个问题相关的帖子,但没有人适合我的情况。我在 Visual Studio 上使用带有 C# 的 oracle 数据库
void addUser()
{
OracleCommand cmd = new OracleCommand();
string query ="INSERT INTO users (user_id, f_name, hash, acc_type, cell_no, country, state, city, zip, address, email, img) VALUES ('" + Convert.ToString(username) + "','" + Convert.ToString(f_name) + "','" + password + "','" + acc_type + "','" + contactno + "','" + country + "','" + state + "','" + city + "','" + zip + "','" + address + "','" + email + "',imgByte)";
OracleCommand sc = new OracleCommand(query, usersdb);
sc.Parameters.AddWithValue("imgByte", imgByte);
try
{
usersdb.Open();
sc.ExecuteNonQuery();
usersdb.Close();
lblSignupError.Visible = true;
lblSignupError.Text = "Signed up successfully. You can login now.";
Clear();
LoginNow();
}
catch (Exception ex)
{
Console.WriteLine(ex);
if (usersdb.State == ConnectionState.Open)
{
usersdb.Close();
}
}
}
这是注册在数据库中添加用户的代码,但出现此错误
***抛出异常:System.Data.OracleClient.dll System.Data.OracleClient.OracleException (0x80131938) 中的“System.Data.OracleClient.OracleException”:ORA-01036:非法变量名称/编号
在 System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) 在 System.Data.OracleClient 的 System.Data.OracleClient.OracleParameterBinding.Bind(OciStatementHandle statementHandle, NativeBuffer parameterBuffer, OracleConnection connection, Boolean& mustRelease, SafeHandle& handleToBind)。 OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior 行为, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals) at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciRowidDescriptor& rowidDescriptor) at System.Data.OracleClient.OracleCommand.ExecuteNonQuery() at StopNShop .SignUpForm.addUser() 在 E:\Visual Studio Projects\StopNShop\StopNShop\SignUpForm.cs:line 402***