Click to See Complete Forum and Search --> : how to validate user loging using SQL server stored procedure with ASP.net by C#


dinal
June 5th, 2006, 02:32 PM
hi friends,
if anybody can help me to validate user loging using SQL server stored procedure with ASP.net by C#..i created up to some extent..but ther's error in this part >>>>>

command.ExecuteNonQuery();

i= Convert.ToInt32(valid_customer.Value);
sss.Close();

----------------------------------------------------------------------------------------------

public int login_check(string F_username, string F_password)
{

try
{

DB_Connection db = new DB_Connection();
SqlConnection sss = db.openConnection();

SqlCommand command = new SqlCommand ("EXECUTE validatelog ?,? ,? output",sss);

if(sss.State .ToString ()=="Closed")
{
sss.Open() ;
}
else
{

command.CommandType = CommandType.StoredProcedure;

command.Parameters.Add("@username",SqlDbType.VarChar).Value=F_username;
command.Parameters.Add("@password",SqlDbType.VarChar).Value=F_password;

SqlParameter valid_customer= new SqlParameter("@numCust",SqlDbType.Int);
valid_customer.Direction=ParameterDirection.Output;
command.Parameters.Add(valid_customer);

command.ExecuteReader();

i= Convert.ToInt32(valid_customer.Value);
sss.Close();
}
}
catch(SqlException sdfd)
{
System.Console.WriteLine(sdfd);
}
return i;
}

Rohit Kukreti
June 26th, 2006, 01:49 PM
I cudn't find anything called DB_Connection db = new DB_Connection();

Use the namespace System.Data.SqlClient;

and write the following code for executing the SP

SqlConnection con = new SqlConnection("Constr");
con.Open();
SqlCommand cmd = new SqlCommand("Exec proc", con);

Alsvha
June 27th, 2006, 02:38 AM
What is the error returned from your code?