当前位置: 首页>>代码示例>>C#>>正文


C# SqlDataSource.Update方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.SqlDataSource.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataSource.Update方法的具体用法?C# SqlDataSource.Update怎么用?C# SqlDataSource.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.SqlDataSource的用法示例。


在下文中一共展示了SqlDataSource.Update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load_Logo

        private void Load_Logo()
        {
            string connectionstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selectstring = "SELECT ADMIN_LOGONAME FROM ADMINISTRATOR WHERE USER_ID = 0";

            SqlDataSource database = new SqlDataSource(connectionstring, selectstring);
            DataView dv = (DataView)database.Select(DataSourceSelectArguments.Empty);
            string filename = (string)dv.Table.Rows[0][0];

            if (System.IO.File.Exists(Server.MapPath("~/Content/") + filename) == true)
            {
                LogoImage.ImageUrl = "~/Content/" + filename;
            }
            else
            {
                LogoImage.ImageUrl = "~/Content/" + "evansville_day_school.jpg";

                string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                string selstring = "SELECT * FROM ADMINISTRATOR WHERE USER_ID = 0";
                string updatestring = "UPDATE ADMINISTRATOR SET ADMIN_LOGONAME = 'evansville_day_school.jpg' WHERE USER_ID = 0";
                SqlDataSource db = new SqlDataSource(connstring, selstring);
                db.UpdateCommand = updatestring;
                db.Update();
            }

            dv.Dispose();
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:27,代码来源:AccountInformationPage.aspx.cs

示例2: UploadNewLogoButton_Click

        protected void UploadNewLogoButton_Click(object sender, EventArgs e)
        {
            string filename = FileUpload1.FileName;
            string extension = "";

            if (FileUpload1.HasFile == true)
            {
                extension = filename.Substring(filename.Length - 4);
            }

            if (extension == ".jpg" || extension == ".png" || extension == ".gif" & FileUpload1.HasFile == true)
            {
                string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                string selstring = "SELECT * FROM ADMINISTRATOR WHERE USER_ID = 0";
                string updatestring = string.Format("UPDATE ADMINISTRATOR SET ADMIN_LOGONAME = '{0}' WHERE USER_ID = 0", filename);
                SqlDataSource db = new SqlDataSource(connstring, selstring);
                db.UpdateCommand = updatestring;
                db.Update();

                string rootpath = Server.MapPath("~/");

                FileUpload1.PostedFile.SaveAs(rootpath + "/Content/" + filename);

                LogoImage.ImageUrl = ("~/Content/" + filename);

                Server.Transfer("OrganizationManagement.aspx");
            }
            else if (FileUpload1.HasFile == false)
            {
                Label1.Text = "No file chosen.";
                Label1.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                Label1.Text = "ERROR: IMAGE MUST BE .JPG, .PNG, OR .GIF.";
                Label1.ForeColor = System.Drawing.Color.Red;
            }
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:38,代码来源:Update+Logo+Page.aspx.cs

示例3: SaveChangesButton_Click

        protected void SaveChangesButton_Click(object sender, EventArgs e)
        {
            string securitycode;
            string connstring;
            string selstring;
            string updatestring;
            SqlDataSource db;

            if (RadioButtonList.SelectedValue == "Activated")
            {

                securitycode = TextBox1.Text;

                connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                selstring = "SELECT * FROM ADMINISTRATOR WHERE USER_ID = 0";
                updatestring = string.Format("UPDATE ADMINISTRATOR SET ADMIN_SECURITYCODE = '{0}' WHERE USER_ID = 0", securitycode);
                db = new SqlDataSource(connstring, selstring);
                db.UpdateCommand = updatestring;
                db.Update();
            }
            else if (RadioButtonList.SelectedValue == "Deactivated")
            {
                securitycode = "No Code Set";

                connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                selstring = "SELECT * FROM ADMINISTRATOR WHERE USER_ID = 0";
                updatestring = string.Format("UPDATE ADMINISTRATOR SET ADMIN_SECURITYCODE = '{0}' WHERE USER_ID = 0", securitycode);
                db = new SqlDataSource(connstring, selstring);
                db.UpdateCommand = updatestring;
                db.Update();
            }
            else
            {
            }

            Server.Transfer("OrganizationManagement.aspx");
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:37,代码来源:Organization+Security+Code+Page.aspx.cs

示例4: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selstring = "SELECT * FROM SUBSCRIPTION JOIN USERS ON USERS.USER_ID = SUBSCRIPTION.USER_ID JOIN LIST ON SUBSCRIPTION.LIST_ID =  LIST.LIST_ID";

            string phone = Label1.Text + Label4.Text + Label5.Text;
            string fname = Label2.Text;
            string lname = Label3.Text;
            string lists = Label6.Text;

            SqlDataSource db = new SqlDataSource(connstring, selstring);
            DataView dv = (DataView)db.Select(DataSourceSelectArguments.Empty);
            string FirstName = (string)dv.Table.Rows[0][4];
            string LastName = (string)dv.Table.Rows[0][5];
            string Phone = (string)dv.Table.Rows[0][6];
            int userid = (int)dv.Table.Rows[0][0];
            string updatestring = String.Format("UPDATE USERS SET USER_FNAME={0}, USER_LNAME={1}, USER_PHONE={2} WHERE USER_ID={3};", fname, lname, phone, userid);
            db.UpdateCommand = updatestring;
            //db.InsertCommand = insertstring;

            if (FirstName == Label2.Text && LastName == Label3.Text)
            {
                string firstUpdateString = String.Format("UPDATE USERS SET USER_FNAME={0}, USER_LNAME={1}, USER_PHONE={2} WHERE USER_ID={3};", fname, lname, phone, userid);
                db.UpdateCommand = updatestring;
                db.Update();
            }
            else
            {
                string insertstring = String.Format("INSERT INTO USERS VALUES {0},{1},{2}", fname, lname, phone);
                db.Insert();
                insertstring = String.Format("INSERT INTO SUBSCRIPTION VALUES {0}", lists);
                db.InsertCommand = insertstring;
                db.Insert();
            }

            Response.Redirect("TextAlertRegistration.aspx");
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:37,代码来源:regConf.aspx.cs

示例5: Button1_Click

        //Buying more Tokens
        protected void Button1_Click(object sender, EventArgs e)
        {
            int temp1 = 0, temp2 = 0, FinalTokenCount = 0;

            //Finds which checkboxes are chosen
            foreach (ListItem item in CheckBoxList3.Items)
            {
                if (item.Selected)
                {
                    if (item.Value == "100")
                    {
                        temp1 = 100;
                    }

                    else if (item.Value == "250")
                    {
                        temp1 = 250;
                    }

                    else if (item.Value == "500")
                    {
                        temp1 = 500;
                    }

                    else if (item.Value == "1,000")
                    {
                        temp1 = 1000;
                    }

                    else if (item.Value == "2,000")
                    {
                        temp1 = 2000;
                    }

                    else if (item.Value == "5,000")
                    {
                        temp1 = 5000;
                    }

                    else if (item.Value == "10,000")
                    {
                        temp1 = 10000;

                    }

                    else { }

                    //Adds all the checkboxes together
                    FinalTokenCount = temp1 + temp2;
                    temp2 = temp1 + temp2;
                    temp1 = 0;

                    string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                    string selstring = "SELECT * FROM ADMINISTRATOR";
                    SqlDataSource db = new SqlDataSource(connstring, selstring);
                    DataView dv = (DataView)db.Select(DataSourceSelectArguments.Empty);
                    int dbTokens = (int)dv.Table.Rows[0][1];
                    FinalTokenCount = FinalTokenCount + dbTokens;
                    string updatestring = String.Format("UPDATE ADMINISTRATOR SET ADMIN_TOKENS = {0}", FinalTokenCount);
                    string finalTokens = Convert.ToString(FinalTokenCount);
                    db.UpdateCommand = updatestring;
                    db.Update();

                    Response.Redirect("AddTokens.aspx");
                    //AddFinalTokenCount to database
                    //Change token count on label 1
                }
            }
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:70,代码来源:AddTokens.aspx.cs


注:本文中的System.Web.UI.WebControls.SqlDataSource.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。