예제 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = null;

        try
        {
            con = DBLogic.GetConnection();

            con.Open();
            //build a query
            String     query = "update reg set password = '******' ,emailid='" + txtemail.Text + "'  where userid = '" + txtuserid.Text + "'";
            SqlCommand com   = new SqlCommand(query, con);

            //call the method of command object
            int result = com.ExecuteNonQuery();

            if (result > 0)
            {
                Label4.Text = "Record is UPDATED successfully";
            }
        }
        catch (Exception err)
        {
            Label4.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
예제 #2
0
    public static RegInfo SearchSingleRecord(String uid)
    {
        SqlConnection con    = null;
        RegInfo       regobj = new RegInfo();

        try
        {
            con = DBLogic.GetConnection();
            con.Open();
            String query = "select * from reg where userid = '" + uid + "'";

            SqlCommand com = new SqlCommand(query, con);

            SqlDataReader dr = com.ExecuteReader();

            dr.Read();

            regobj.UserId  = dr[0].ToString();
            regobj.Pass    = dr[1].ToString();
            regobj.EmailId = dr[2].ToString();
        }
        catch (Exception err)
        {
            //Label1.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
        return(regobj);
    }
예제 #3
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        SqlConnection con = null;

        Label1.Text = DropDownList1.SelectedValue;
        try
        {
            con = DBLogic.GetConnection();

            String query = "select * from reg where userid = '" + DropDownList1.SelectedValue + "'";

            //create the SqlDataAdapter object
            SqlDataAdapter da = new SqlDataAdapter(query, con);

            //create the object Dataset
            DataSet ds = new DataSet();

            //Call the fill Method and pass the
            //DataSet object
            da.Fill(ds);

            //get the no of tables dataset contains
            DataTable dt = ds.Tables[0];

            //bind the dataset table with the GridView
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        catch (Exception err)
        {
            Label1.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
예제 #4
0
    public static DataTable FetchAllRecord()
    {
        SqlConnection con = null;
        DataTable     dt  = null;

        try
        {
            con = DBLogic.GetConnection();

            String query = "select * from reg ";

            //create the SqlDataAdapter object
            SqlDataAdapter da = new SqlDataAdapter(query, con);

            //create the object Dataset
            DataSet ds = new DataSet();

            //Call the fill Method and pass the
            //DataSet object
            da.Fill(ds);

            //get the no of tables dataset contains
            dt = ds.Tables[0];
        }
        catch (Exception err)
        {
            //Label1.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
        return(dt);
    }
예제 #5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = null;

        try
        {
            con = DBLogic.GetConnection();
            con.Open();
            String query = "select * from reg where userid = '" + txtuserid.Text + "' and password = '******'";

            SqlCommand com = new SqlCommand(query, con);

            SqlDataReader dr = com.ExecuteReader();

            if (dr.Read())
            {
                Session["uid"] = txtuserid.Text;
                Response.Redirect("AfterLogin.aspx");
            }
            else
            {
                Label4.Text = "INVALID UID OR PASS";
            }
        }
        catch (Exception err)
        {
            Label4.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }