Пример #1
0
    protected void AddUser()
    {
        string username = Username.Text.Trim();
        string password = Password.Text.Trim();

        string sql1 = String.Format("insert into [user_info](username, password) values('{0}', '{1}')", username, password);
        //string sql2 = "select * from [user_info] where username = @username and password = @password";
        //string sql3 = "select * from [user_info] where username = @username and password = @password";

        //string tmp  = String.Format("select count([user_id]) from [user_info] where [username] = '{0}'", username);
        string all = "select * from [user_info]";


        SqlParameter[] param = new SqlParameter[]
        {
            new SqlParameter("@username", Username.Text.Trim()),
            new SqlParameter("@password", Password.Text.Trim())
        };

        try
        {
            Connector msConn = ConnecterFactory.GetConnector("TestDB");

            msConn.ManageDataOffMode("insert", "user_info", username, password);

            DataSet ds = msConn.GetDataSet(all);

            ViewData1.DataSource = ds;
            ViewData1.DataBind(); // this case, has no bug. why?
        }
        catch (Exception ex)
        {
            prompt.InnerText = ex.Message;
        }
    }
Пример #2
0
    protected void UpdateBtn_Click(object sender, EventArgs e)
    {
        string username = Username.Text.Trim();
        string password = Password.Text.Trim();

        string sql1 = String.Format("insert into [user_info](username, password) values('{0}', '{1}')", username, password);
        string all  = "select * from [user_info]";


        SqlParameter[] param = new SqlParameter[]
        {
            new SqlParameter("@username", Username.Text.Trim()),
            new SqlParameter("@password", Password.Text.Trim())
        };

        try
        {
            Connector msConn = ConnecterFactory.GetConnector("TestDB");

            msConn.ManageDataOffMode("update", "user_info", 7, username, password);

            DataSet ds = msConn.GetDataSet(all);

            ViewData1.DataSource = ds;
            ViewData1.DataBind(); // this case, has no bug. why?
        }
        catch (Exception ex)
        {
            prompt.InnerText = ex.Message;
        }
    }
Пример #3
0
    protected void DeleteBtn_Click(object sender, EventArgs e)
    {
        string username = Username.Text.Trim();
        string password = Password.Text.Trim();

        string all = "select * from [user_info]";


        SqlParameter[] param = new SqlParameter[]
        {
            new SqlParameter("@username", Username.Text.Trim()),
            new SqlParameter("@password", Password.Text.Trim())
        };

        try
        {
            Connector msConn = ConnecterFactory.GetConnector("TestDB");

            msConn.ManageDataOffMode("delete", "user_info", username, password);

            DataSet ds = msConn.GetDataSet(all);

            ViewData1.DataSource = ds;
            ViewData1.DataBind();
        }
        catch (Exception ex)
        {
            prompt.InnerText = ex.Message;
        }
    }
Пример #4
0
    protected void SignInBtn_Click(object sender, EventArgs e)
    {
        mssql.CreateConnection();

        try
        {
            // 连接模式访问

            // mssql.OpenDb();

            string username = Username.Text.Trim();
            string password = Password.Text.Trim();

            string[] arr = { "@username", "@password", "10", "10", username, password };

            string[] arr1 = { username, password, "10", "10" };


            ViewData1.DataSource = mssql.SelectData("select * from user_info where username = @username and password = @password", arr1);
            ViewData1.DataBind();

            mssql.CloseReader(); // 关闭reader

            //ViewData2.DataSource = mssql.SelectData("*", "user_info", arr);
            //ViewData2.DataBind();

            //mssql.CloseReader(); // 关闭reader

            mssql.CloseDb();
        }
        catch (Exception ex)
        {
            prompt.InnerText = ex.Message;
        }
    }