This is my code
I am getting following Error
ERROR:Server Error in '/' Application.
Incorrect syntax near the keyword 'User'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'User'.
string strConnection = ConfigurationManager.ConnectionStrings["stgdbConnectionString"].ConnectionString;
string strSelect = "SELECT Username,Password FROM User WHERE Username = @Username";
SqlConnection connection = new SqlConnection(strConnection);
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = strSelect;
SqlParameter email = new SqlParameter("@Username", SqlDbType.VarChar, 30);
email.Value = TextBox1.Text.Trim().ToString();
command.Parameters.Add(email);
//Create Dataset to store results and DataAdapter to fill Dataset
DataSet dsPwd = new DataSet();
SqlDataAdapter dAdapter = new SqlDataAdapter(command);
connection.Open();
dAdapter.Fill(dsPwd);
connection.Close();
if (dsPwd.Tables[0].Rows.Count > 0)
{
System.Net.Mail.MailMessage loginInfo = new System.Net.Mail.MailMessage();
loginInfo.To.Add(TextBox1.Text.ToString());
loginInfo.From = new MailAddress("a@gmail.com");
//loginInfo.Subject = "Forgot Password Information";
loginInfo.Body =TextBox2.Text+ "UserName: " + dsPwd.Tables[0].Rows[0]["Username"] + "Password: " + dsPwd.Tables[0].Rows[0]["Password"] + "";
loginInfo.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("a@gmail.com", "a");
smtp.Send(loginInfo);
//Label1.Text = "Password is sent to you email id,you can now <a href='Login.aspx'>Login</a>";
}
else
{
Label1.Text = "Email Address Not Registered";
}