I am developing (converting application db from MS SQL to MySQL) an application using C#.Net and MySQL. My C# code and stored procedure is working perfect in MS SQL but when trying to ingrate with MySQL getting parameter error. My C# Code is as below and MySQL Stored Procedure is running perfectly (tested in editor using CALL key work and parameter)
public DataTable AlapValidateUser(string email, string password,string Type)
{
DataTable dt = new DataTable();
cmd = new MySqlCommand("UserIdValidation");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = cnn;
string pass = reEncryptpassword(password);
MySqlParameter pramEmail = new MySqlParameter("@v_emailId", email);
pramEmail.Direction = ParameterDirection.Input;
cmd.Parameters.Add(pramEmail);
MySqlParameter pramPassword = new MySqlParameter("@v_password", pass);
pramPassword.Direction = ParameterDirection.Input;
cmd.Parameters.Add(pramPassword);
MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
if (cnn.State != ConnectionState.Open ||
cnn.State == ConnectionState.Broken ||
cnn.State != ConnectionState.Connecting ||
cnn.State != ConnectionState.Executing ||
cnn.State != ConnectionState.Fetching)
cnn.Open();
adap.Fill(dt);
cnn.Close();
return dt;
}
MySQL Stored Procedure is here:
CREATE DEFINER=`root`@`localhost` PROCEDURE `UserIdValidation`(v_emailId NATIONAL VARCHAR(100),v_password
NATIONAL VARCHAR(50))
BEGIN
SELECT UserId ,eMail,BloodGroup
,BloodGroupID,Country AS CountrySlNo ,CountryName ,State ,District
,Location,fName,lName ,DonorType ,LastLogIn ,Validated ,ProfileImage
,MaritalStatus ,Sex ,Height ,Weight ,HealthStatus
,MyFileLocation FROM vwUser WHERE eMail = v_emailId AND
PASSWORD = v_password AND Validated = 'Y';
END$$
During execution exception as below:
"Incorrect number of arguments for PROCEDURE alap.UserIdValidation; expected 2, got 1"
Already I have tried by changing parameter entry by below code:
cmd.Parameters.Add(new MySqlParameter("@v_emailId", email)); cmd.Parameters.Add(new MySqlParameter("@v_password", pass));
and @ with ? and without @ or ? but nothing works.
Can you please help me to find out the error. Is it a bug of mysql connector?
UPDATE: My MySQL connector is v.6.6.5. I have checked in debug mode in C# parameter is correct and can see both paramter in command object. Next it is trying to filling Adapter hence this command object is passing to MySQL from Connector and there paramter is missing. I have tried to add same 1st parameter by creating 3rd line then gettinng error that same paramter already exist.
From this test I am sure it is purely MySQL or mysql connector bug.
I dont know how this bug can exists in such DB where so many people is using mysql.
Thanks Suman
public DataTable AlapValidateUser(string email, string password,string Type)
{
DataTable dt = new DataTable();
cmd = new MySqlCommand("UserIdValidation");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = cnn;
string pass = reEncryptpassword(password);
MySqlParameter pramEmail = new MySqlParameter("@v_emailId", email);
pramEmail.Direction = ParameterDirection.Input;
cmd.Parameters.Add(pramEmail);
MySqlParameter pramPassword = new MySqlParameter("@v_password", pass);
pramPassword.Direction = ParameterDirection.Input;
cmd.Parameters.Add(pramPassword);
MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
if (cnn.State != ConnectionState.Open ||
cnn.State == ConnectionState.Broken ||
cnn.State != ConnectionState.Connecting ||
cnn.State != ConnectionState.Executing ||
cnn.State != ConnectionState.Fetching)
cnn.Open();
adap.Fill(dt);
cnn.Close();
return dt;
}
MySQL Stored Procedure is here:
CREATE DEFINER=`root`@`localhost` PROCEDURE `UserIdValidation`(v_emailId NATIONAL VARCHAR(100),v_password
NATIONAL VARCHAR(50))
BEGIN
SELECT UserId ,eMail,BloodGroup
,BloodGroupID,Country AS CountrySlNo ,CountryName ,State ,District
,Location,fName,lName ,DonorType ,LastLogIn ,Validated ,ProfileImage
,MaritalStatus ,Sex ,Height ,Weight ,HealthStatus
,MyFileLocation FROM vwUser WHERE eMail = v_emailId AND
PASSWORD = v_password AND Validated = 'Y';
END$$
During execution exception as below:
"Incorrect number of arguments for PROCEDURE alap.UserIdValidation; expected 2, got 1"
Already I have tried by changing parameter entry by below code:
cmd.Parameters.Add(new MySqlParameter("@v_emailId", email)); cmd.Parameters.Add(new MySqlParameter("@v_password", pass));
and @ with ? and without @ or ? but nothing works.
Can you please help me to find out the error. Is it a bug of mysql connector?
UPDATE: My MySQL connector is v.6.6.5. I have checked in debug mode in C# parameter is correct and can see both paramter in command object. Next it is trying to filling Adapter hence this command object is passing to MySQL from Connector and there paramter is missing. I have tried to add same 1st parameter by creating 3rd line then gettinng error that same paramter already exist.
From this test I am sure it is purely MySQL or mysql connector bug.
I dont know how this bug can exists in such DB where so many people is using mysql.
Thanks Suman