當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。