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

New Message on BDOTNET

-----------------------------------------------------------
From: PaleriSharath
Message 4 in Discussion

 Hi friends.. This is the solution given to me in the MSDN forum.. Thanks 
Littleguru.. Cheers :-) 
I'll try to answer this :) 
the value returned by the ExecuteNonQuery returns the amount of rows affected 
by an update/delete or insert command. If you want to get the count of rows 
that match your conditions you need to rewrite your code and use 
ExecuteScalar(). 
string connectionString=@"C:\Documents and Settings\shrath1\My Documents\Visual 
Studio 2005\ WebSites\ConfiguringAccessDb\App_Data\IssueTrackingSystem.mdb";

OleDbConnection oleconn = new 
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + 
connectionString);

OleDbCommand olecomm=null; OleDbDataAdapter oledbDataAdapter; DataSet ds=null;

string commandText = "SELECT count(USERNAME) FROM LOGIN WHERE USERNAME = '" + 
Login1.UserName + "'" + " " + "and password='" + Login1.Password + "'"; //= ? 
AND PASSWORD = ?"; 

//olecomm = new OleDbCommand(commandText, oleconn); 
//olecomm.Parameters.Add(new OleDbParameter("@UserName",this.Login1.UserName)); 
//olecomm.Parameters.Add( new OleDbParameter("@Password",this.Login1.Password));

try
{
oleconn.Open();
int count = (int)olecomm.ExecuteScalar();
if (count > 0 & count == 1)
{
Login1.Visible = false;
}
else
{
Login1.FailureText = "Login Failed,Please try again";
}
}
catch (InvalidOperationException ie)
{
Login1.FailureText = "Sorry for the Inconvnience";
} 

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

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to