MySQL Forums
Forum List  »  MySQL for Visual Studio

Login error in ASP.NET using MySQL
Posted by: bakhtawar ashiq
Date: September 22, 2014 12:53AM

I try to create login function in ASP.NET using MySQL database and enterprise library.

First I create a database and store procedures.

spselectusertype sp

DELIMITER //


Create procedure spselectusertype(
UName varchar(50),
Pasword varchar(50)
)
BEGIN
Select UserType_ID FROM login
WHERE UName = UName AND UPasword = Pasword;
end;

splogin sp

create procedure splogin()
BEGIN
SELECT *
FROM login
WHERE UName = UName and UPasword=UPasword;
END

Then I create a class library and add these functions:

Database db = DatabaseFactory.CreateDatabase("abc");

public int UserType(string UName, string UPasword)
{
return Convert.ToInt32(db.ExecuteScalar("spselectusertype", new object[] {
UName, UPasword }).ToString());
}
public int SignInUsers(string UName, string Pasword)
{
return Convert.ToInt32(db.ExecuteScalar("splogin", new object[] { UName, Pasword }));
}

Login button code:

MySqlConnection conn = new
MySqlConnection(ConfigurationManager.ConnectionStrings["abc"].ConnectionString);

ClassLibrary1.Class1 LOGIN = new ClassLibrary1.Class1();




protected void Button1_Click1(object sender, EventArgs e)
{

//UsertpeTID sve in session
int users = LOGIN.UserType(TextBox1.Text, TextBox2.Text);



//UserID Save in Session
int user_id = Convert.ToInt16(LOGIN.SignInUsers(TextBox1.Text, TextBox2.Text));
Session["UserID"] = user_id;

if (Session["UserID"] != null)
{
user_id = Convert.ToInt32(Session["UserID"].ToString());
}
if (users == 1)
{
Session["Login2"] = TextBox1.Text;
Session["Login3"] = TextBox2.Text;

Session["UserTypeID"] = users;

Response.Redirect("alldocuments.aspx");
}
else if (users == 2)
{


Session["Login2"] = TextBox1.Text;
Session["Login3"] = TextBox2.Text;

Session["UserTypeID"] = users;

Response.Redirect("Home.aspx");
Label3.Visible = true;
Label3.Text = "Incorrect User Name or Password";
}
}

}

}

But when I debug my project and enter username and password, it shows me following error

Parameter discovery is not supported for connections using GenericDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.

on this line:

return Convert.ToInt32(db.ExecuteScalar("spselectusertype", new object[] {
UserName, UserPassword }).ToString());

So where is the mistake?

Options: ReplyQuote


Subject
Views
Written By
Posted
Login error in ASP.NET using MySQL
2525
September 22, 2014 12:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.