hi
coding for forget password through gmail is working fine my question is how to check wheather email id is there in database or not if its not there execute please register first. how write coding for this
coding
using (SqlConnection con = new SqlConnection(_constr))
{
string query = "select Password,email from login where email='" + txtemail.Text + "'";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
int rowcount = ds.Tables[0].Rows.Count;
if (rowcount > 0)
{
email = ds.Tables[0].Rows[0]["email"].ToString();
password = ds.Tables[0].Rows[0]["password"].ToString();
MailMessage mail = new MailMessage();
mail.From = new MailAddress("gmailid");
mail.To.Add(email);
mail.Subject = "Reg. Password ";
mail.Body = " Your Password for the user" + " " + txtemail.Text.ToString() + " " + " is " + password;
mail.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("gmailid", "password");
client.Port = 587; // Gmail works on this port
client.Host = "smtp.gmail.com";
client.EnableSsl = true; //Gmail works on Server Secured Layer
//lbl6.Text = " The password has successfully sent to " + email;
client.Send(mail);
}
}
my database coding is:
CREATE PROCEDURE CheckUserName( @email VARCHAR(50) )
AS
BEGIN
IF EXISTS (SELECT COUNT(email) FROM email WHERE [email] = @email )
SELECT '1'; --user name already exist in database
ELSE
SELECT '0'; --user name does not exist in database
END
sankarreddy