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


C# SqlDataSource.Update方法代码示例

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


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

示例1: btnUpdate_Click

    //按鈕更新
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        //壓縮圖片並存檔
        CImageProess.get().UploadImage(FileUpload1, 資料夾路徑, CDictionary.SET_BRAND_PX);

        x = new SqlDataSource();
        x.ConnectionString = CDictionary.CONN_URL;

        string sql = "UPDATE Company set ";
        if (!string.IsNullOrEmpty(txtContent.Text))
        {
            sql += " name=N'" + txtName.Text + "', ";
            if (FileUpload1.HasFile)
                sql += " picBrandPath='" + CImageProess.imageName + "', ";
            sql += " manager=N'" + txtManager.Text + "', ";
            sql += " tel=N'" + txtPhone.Text + "', ";
            sql += " sparEmail=N'" + txtSpareEmail.Text + "', ";
            sql += " addr=N'" + txtAddress.Text + "', ";
            sql += " content=N'" + txtContent.Text + "' ";
            sql += "WHERE companyID='" + companyID + "'";

            x.UpdateCommand = sql;
            x.Update();
        }
        else
            return;

        Response.Write("<script>alert('更改資料成功!')</script>");
        Response.Write("<script>location.href='companyCheck.aspx'</script>");
    }
开发者ID:CYHuangMike,项目名称:Collections,代码行数:31,代码来源:companyDetail.aspx.cs

示例2: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource sqldatasource2 = new SqlDataSource();
            sqldatasource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
            sqldatasource2.UpdateParameters.Add("Order_date", TextBox1.Text);
            sqldatasource2.UpdateParameters.Add("Assign_numbers", TextBox2.Text);
            sqldatasource2.UpdateParameters.Add("Account_numbers", DropDownList1.Text);
            sqldatasource2.UpdateParameters.Add("Account_abstract", TextBox3.Text);
            sqldatasource2.UpdateParameters.Add("Income", TextBox4.Text);
            sqldatasource2.UpdateParameters.Add("Spend", TextBox5.Text);
            sqldatasource2.UpdateCommand = "Update [Account_Order_M] set [email protected]_date, [email protected]_numbers, [email protected]_numbers, [email protected]_abstract, [email protected], [email protected] where Id="+Request["Id"];

            int affraw_update = sqldatasource2.Update();

            if (affraw_update == 0)
            {
                Label1.Text = "error";
            }
            else
            {
                Label1.Text = "ok";
                Button1.Visible = false;
            }
            sqldatasource2.Dispose();
    }
开发者ID:keithliang,项目名称:PersonalProducts_Account,代码行数:25,代码来源:UpdateJournalUpdate.aspx.cs

示例3: btnNewsUpdate_Click

    protected void btnNewsUpdate_Click(object sender, EventArgs e)
    {
        //actID 已知的活動代碼
        //用where查狀態是否還為"待審中"
        //是待審中再進行更新動作
        //是上架就進行Question 警告使用者 更新後, 將重新送審
        x = new SqlDataSource();
        x.ConnectionString = @"Data Source=iii0.database.windows.net;Initial Catalog=prjTRK;Persist Security Info=True;User ID=iii;[email protected]";
        x.SelectCommand = "Select *from Promotions where activityID ='" + activity.Text + "'";
        DataView dv = x.Select(DataSourceSelectArguments.Empty) as DataView;
        statusID = dv.Table.Rows[0]["statusID"].ToString();

        if (statusID == "3" || statusID == "4")
        {
            //壓縮圖片並存檔
            CImageProess.get().UploadImage(FileUpload1, 資料夾路徑, CDictionary.SET_PROMOTION_PX);

            x = new SqlDataSource();
            x.ConnectionString = @"Data Source=iii0.database.windows.net;Initial Catalog=prjTRK;Persist Security Info=True;User ID=iii;[email protected]";

            string sql = "UPDATE Promotions set ";
            if (!string.IsNullOrEmpty(titleInput.Text))
            {
                sql += " title=N'" + titleInput.Text + "', ";
                if (FileUpload1.HasFile)
                    sql += " picPath='" + CImageProess.imageName + "', ";
                sql += " startDate='" + startDate.Text + "', ";
                sql += " endDate='" + endDate.Text + "', ";
                sql += " onShelfDate = convert(varchar, DATEADD(hour, 8, GETUTCDATE()), 113)," ;
                sql += " statusID = 3 ,";
                sql += " content=N'" + txtNewsContent.Text + "' ";
                sql += " WHERE activityID='" + activity.Text + "'";
                x.UpdateCommand = sql;
                x.Update();
                Response.Redirect("~/windowCompany/companyCheck.aspx");
            }
            else
                return;
        }
        else
            return;
    }
开发者ID:CYHuangMike,项目名称:Collections,代码行数:42,代码来源:companyUpdate.aspx.cs

示例4: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource sqldatasource2 = new SqlDataSource();
        sqldatasource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
        sqldatasource2.UpdateParameters.Add("Lottery", DropDownList1.Text);
        sqldatasource2.UpdateCommand = "Update [Account_Order_M] set [email protected] where Id=" + Request["Id"];

        int affraw_update = sqldatasource2.Update();

        if (affraw_update == 0)
        {
            Label8.Text = "error";
        }
        else
        {
            Label8.Text = "ok";
            Button1.Visible = false;
        }
        sqldatasource2.Dispose();
    }
开发者ID:keithliang,项目名称:PersonalProducts_Account,代码行数:20,代码来源:LottoReceiptUpdate.aspx.cs

示例5: set_seat

    public void set_seat()
    {
        String Route1 = Request.QueryString["Route1"];
        String Route2 = Request.QueryString["Route2"];

        String Seat_Q_R1 = Request.QueryString["S_R1"];
        String Seat_Q_R2 = Request.QueryString["S_R2"];
        String[] Seat_R1 = {};
        String[] Seat_R2 = {};

        SqlDataSource seat = new SqlDataSource();
        seat.ConnectionString =
            ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();
        seat.UpdateCommand = "UPDATE [Seat] SET [Seat_Status] = @Seat_Status "
            +"WHERE [Route_has_Bus_ID] = @Route_has_Bus_ID AND [Seat_Name] = @Seat_Name";

        if (Seat_Q_R1 != null)
        {
            if (Seat_Q_R1.ToString() != "")
            {
                Seat_R1 = Seat_Q_R1.Split('_');
            }
        }

        if (Seat_Q_R2 != null)
        {
            if (Seat_Q_R2.ToString() != "")
            {
                Seat_R2 = Seat_Q_R2.Split('_');
            }
        }

        if (Route1 != null)
        {
            if (Route1.ToString() != "")
            {
                for (int i = 0; i < Seat_R1.Length; i++)
                {
                    seat.UpdateParameters.Clear();
                    seat.UpdateParameters.Add("Seat_Status", "จอง");
                    seat.UpdateParameters.Add("Route_has_Bus_ID", Route1.ToString());
                    seat.UpdateParameters.Add("Seat_Name", Seat_R1[i]);
                    seat.Update();
                }
            }
        }
        if (Route2 != null)
        {
            if (Route2.ToString() != "")
            {
                for (int i = 0; i < Seat_R2.Length; i++)
                {
                    seat.UpdateParameters.Clear();
                    seat.UpdateParameters.Add("Seat_Status", "จอง");
                    seat.UpdateParameters.Add("Route_has_Bus_ID", Route2.ToString());
                    seat.UpdateParameters.Add("Seat_Name", Seat_R2[i]);
                    seat.Update();
                }
            }
        }
    }
开发者ID:chagridsada,项目名称:BusTicket-Online,代码行数:61,代码来源:Detail.aspx.cs


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