chek dis code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void loginn_Click(object sender, EventArgs e)
{
validateuser(txtusername.Text.Trim(), txtpassword.Text.Trim());
}
public void validateuser(string user, string pass)
{
string strconnection = "Server=sun ;database=test;uid=sa;pwd=sa;";
SqlConnection sqrconnection = new SqlConnection(strconnection);
String SQLQuery = "SELECT username,password FROM usertable where username='" + txtusername.Text + "' and password='" + txtpassword.Text + "'";
SqlCommand command = new SqlCommand(SQLQuery, sqrconnection);
sqrconnection.Open();
DataTable dt = new DataTable();
SqlDataAdapter ad = new SqlDataAdapter(command);
ad.Fill(dt);
if (dt.Rows.Count > 0)
{
Response.Redirect("Default.aspx");
}
else
{
Response.Write("INVALID Username and Password, Try Again!");
}
sqrconnection.Close();
}
}
Radhekrisna, if this helps please login to Mark As Answer. | Alert Moderator