zoukankan      html  css  js  c++  java
  • insert语句太长,有StringBuilder优化一下

     private void btnSave_Click(object sender, RoutedEventArgs e)
            {
                if (IsInsert)
                {
                    //假设日历控件没有选日期,那帮它赋一个当前日期。以下有三个日历控件中,我仅仅为当中一个日历控件做了赋值。

    DateTime time1 = dpEditTime.SelectedDate == null ?

    DateTime.Now : dpEditTime.SelectedDate.Value; DataUpdate updata = new DataUpdate(); string sql = "insert into T_SITE (SITE_ID,SITE_NAME,SITE_TITLE,SITE_DIR,SITE_ORDER,SITE_KEYS,SITE_NOTE,SITE_LOGO,SITE_PUBLISH,SITE_PUBLISH_TIME,SITE_LOG_CLEAR,SITE_UPLOAD_SIZE,SITE_ADD_TIME,SITE_UPDATE_TIME,SITE_UPLOAD_FILE_TYPE) values('" + txtSiteID.Text + "','" + txtSiteName.Text + "','" + txtSiteTitle.Text + "','" + txtSitePath.Text + "','" + txtSiteNumber.Text + "','" + txtKeyword.Text + "','" + txtWebDescription.Text + "','" + txtSiteLogo.Text + "','" + txtYesNORelease.Text + "',to_date('" +txtReleaseTime.SelectedDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "','YYYY-MM-DD hh24:mi:ss'),'" + txtDiaryEDay.Text + "','" + txtUpFileSize.Text + "',to_date('" +dpAddTime.SelectedDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "','YYYY-MM-DD hh24:mi:ss'),to_date('" + time1.ToString("yyy-MM-dd hh:mm:ss") + "','YYYY-MM-DD hh24:mi:ss'),'" + txtUpFileTypeLimit.Text + "')"; //insert语句太长,有StringBuilder优化一下 StringBuilder sql1 = new StringBuilder(); sql1.Append(@"insert into T_SITE (SITE_ID,SITE_NAME,SITE_TITLE,SITE_DIR,SITE_ORDER,SITE_KEYS,SITE_NOTE,SITE_LOGO,SITE_PUBLISH,SITE_PUBLISH_TIME,SITE_LOG_CLEAR,SITE_UPLOAD_SIZE,SITE_ADD_TIME,SITE_UPDATE_TIME,SITE_UPLOAD_FILE_TYPE) values('"); sql1.Append(txtSiteID.Text); sql1.Append("','"); sql1.Append(txtSiteName.Text); sql1.Append("','"); sql1.Append(txtSiteTitle.Text); sql1.Append("','"); sql1.Append(txtSitePath.Text); sql1.Append("','"); sql1.Append(txtSiteNumber.Text); sql1.Append("','"); sql1.Append(txtKeyword.Text); sql1.Append("','"); sql1.Append(txtWebDescription.Text); sql1.Append("','"); sql1.Append(txtSiteLogo.Text); sql1.Append("','"); sql1.Append(txtYesNORelease.Text); sql1.Append("',to_date('"); sql1.Append(txtReleaseTime.SelectedDate.Value.ToString("yyyy-MM-dd hh:mm:ss")); sql1.Append("','YYYY-MM-DD hh24:mi:ss'),'"); sql1.Append(txtDiaryEDay.Text); sql1.Append("','"); sql1.Append(txtUpFileSize.Text); sql1.Append("',to_date('"); sql1.Append(dpAddTime.SelectedDate.Value.ToString("yyyy-MM-dd hh:mm:ss")); sql1.Append("','YYYY-MM-DD hh24:mi:ss'),to_date('"); sql1.Append(time1.ToString("yyy-MM-dd hh:mm:ss")); sql1.Append("','YYYY-MM-DD hh24:mi:ss'),'"); sql1.Append(txtUpFileTypeLimit.Text); sql1.Append("')"); MessageBox.Show(sql1.ToString()); updata.DataObjects.Add(sql1.ToString()); updata.DataObjects.Add(sql); updata = m_IDataProvider.Execute(updata); if (updata.ExecuteState) { MessageBox.Show("插入成功"); } } else { } } } }


  • 相关阅读:
    virtualbox+vagrant学习-2(command cli)-9-vagrant Plugin命令
    virtualbox+vagrant学习-2(command cli)-15-vagrant resume命令
    virtualbox+vagrant学习-2(command cli)-14-vagrant reload命令
    virtualbox+vagrant学习-2(command cli)-12-vagrant Provision命令
    virtualbox+vagrant学习-2(command cli)-11-vagrant PowerShell命令
    java设计模式之单例
    java设计模式之策略
    java设计模式之组合
    设计模式之适配器
    java设计模式之模板方法
  • 原文地址:https://www.cnblogs.com/cynchanpin/p/7270579.html
Copyright © 2011-2022 走看看