The error message returns with that it expected 0 arguments but it got 6
DELIMITER //
CREATE Procedure customer_reg()
BEGIN
INSERT INTO tblcustomers
(customerName, contactNo, Email, Address, Password, DoB)
VALUES
(AES_ENCRYPT(@customerName,'name'),
AES_ENCRYPT(@contactNo, 'con'),
AES_ENCRYPT(@Email,' email'),
AES_ENCRYPT(@Address, 'add'),
AES_ENCRYPT(@Password, 'pass'),
AES_ENCRYPT(@DoB,'dob'));
END //
DELIMITER ;
I'm using the query above to create a procedure customer_reg in order to use customer_reg in a c# form but all values being inserted in the database turn into null values:
if (MessageBox.Show("Register as a customer?", "CONFIRM", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
con.Open();
MySqlCommand cmd = new MySqlCommand("customer_reg", con);
cmd.CommandType = CommandType.StoredProcedure;
// Add parameters to the command
cmd.Parameters.AddWithValue("@customerName", txtName.Text);
cmd.Parameters.AddWithValue("@contactNo", txtPhone.Text);
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
cmd.Parameters.AddWithValue("@DoB", dtpDOB.Value);
// Execute the command
int rowsAffected = cmd.ExecuteNonQuery();
if (rowsAffected > 0)
{
// Retrieve the last inserted ID
cmd.CommandText = "SELECT LAST_INSERT_ID()";
int id = Convert.ToInt32(cmd.ExecuteScalar());
// Display a message
MessageBox.Show("Registered Successfully. Customer ID: " + id.ToString(), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Clear the data
ClearData();
}
else
{
MessageBox.Show("Registration failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
con.Close();
}
}
else
{
ClearData();
}
so what seems to be the problem? what are your thoughts?