婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > sqlserver 批量數(shù)據(jù)替換助手V1.0版發(fā)布

sqlserver 批量數(shù)據(jù)替換助手V1.0版發(fā)布

熱門標(biāo)簽:凱立德地鐵站地圖標(biāo)注 銀行信貸電話機(jī)器人 溫州外呼系統(tǒng)招商 上海400客服電話怎么申請 400電話個(gè)人能不能辦理 天津電銷外呼系統(tǒng)違法嗎 手機(jī)外呼系統(tǒng)什么原理 滄州電銷外呼系統(tǒng)價(jià)格 合肥ai電銷機(jī)器人費(fèi)用
這種方法操作繁瑣,而且一般不是很懂?dāng)?shù)據(jù)庫的人很難操作。于萌發(fā)了要寫一個(gè)小程序的念頭,經(jīng)過兩天時(shí)間的折騰這個(gè)小軟件終于和各位見面了,希望各位童鞋多給點(diǎn)意見。說了這么些之后還是先上界面吧,^..^

現(xiàn)在就來說說這個(gè)小程序的開發(fā)思路吧。
第一步:通過 sp_helpdb系統(tǒng)存儲過程得到SqlServer中的所有數(shù)據(jù)庫名稱。

復(fù)制代碼 代碼如下:

#region 測試數(shù)據(jù)庫連接,并顯示數(shù)據(jù)庫列表
/// summary>
/// 測試數(shù)據(jù)庫連接,并顯示數(shù)據(jù)庫列表
/// /summary>
/// param name="sender">/param>
/// param name="e">/param>
private void btnTest_Click(object sender, EventArgs e)
{
this.btnTest.Enabled = false;
saveConfig();

ConfigInfo.Server = this.txtIP.Text.Trim();
ConfigInfo.DataBase = "master";
ConfigInfo.UID = this.txtUID.Text.Trim();
ConfigInfo.Pwd = this.txtPwd.Text.Trim();

try
{
DataTable dt = Data.SqlHelper.ExecuteDataset(ConfigInfo.getConnect(), CommandType.Text, "sp_helpdb").Tables[0];

this.cmbDataBaseList.DataSource = dt;
this.cmbDataBaseList.DisplayMember = "name";
this.cmbDataBaseList.SelectedIndex = 0;
this.cmbDataBaseList.DropDownStyle = ComboBoxStyle.DropDownList;

this.ExecuteFilterBtn.Enabled = true;
}
catch (Exception ex)
{
this.ExecuteFilterBtn.Enabled = false;
MessageBox.Show(string.Format("錯誤:{0}!",ex.Message),"錯誤提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
this.btnTest.Enabled = true;
}
}
#endregion


第二步:當(dāng)選擇某個(gè)數(shù)據(jù)庫時(shí)得到數(shù)據(jù)庫里面的所有表信息,通過下面Sql語句就可以查詢到了。
select [name] from sysobjects where xtype='u' order by [name] asc

復(fù)制代碼 代碼如下:

#region 當(dāng)選擇不同的數(shù)據(jù)庫時(shí),讀取數(shù)據(jù)庫的表信息
/// summary>
/// 當(dāng)選擇不同的數(shù)據(jù)庫時(shí),讀取數(shù)據(jù)庫的表信息
/// /summary>
/// param name="sender">/param>
/// param name="e">/param>
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.chkboxTableList.Items.Clear();
ConfigInfo.DataBase = ((DataRowView)this.cmbDataBaseList.SelectedItem)["name"].ToString();
DataSet ds = Data.SqlHelper.ExecuteDataset(ConfigInfo.getConnect(), CommandType.Text, "select [name] from sysobjects where xtype='u' order by [name] asc");

foreach (DataRow row in ds.Tables[0].Rows)
{
this.chkboxTableList.Items.Add(row["name"].ToString());
}
}
#endregion


第三步:當(dāng)點(diǎn)擊替換按鈕時(shí)獲取被選中表的信息,并遍歷表中的行列信息,并進(jìn)行查找替換。

復(fù)制代碼 代碼如下:

#region 執(zhí)行批量替換操作
/// summary>
/// 執(zhí)行批量替換操作
/// /summary>
/// param name="sender">/param>
/// param name="e">/param>
private void ExecuteFilterBtn_Click(object sender, EventArgs e)
{
saveConfig();
total = 0;
if (this.chkboxTableList.CheckedIndices.Count == 0) return; //沒有選中任何表的情況
if (this.txtSearchKey.Text.Trim() == "")
{
DialogResult result = MessageBox.Show("當(dāng)前查找內(nèi)容為空,確認(rèn)此操作?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result == DialogResult.No) return;
}

this.ExecuteFilterBtn.Enabled = false;

ListTableInfo> tabList = new ListTableInfo>();
string searchString = this.txtSearchKey.Text.Trim() == "" ? " " : this.txtSearchKey.Text;
string replaceString = this.txtReplaceStr.Text;
KeyType kt = this.chkIsRegex.Checked == true ? KeyType.Regex : KeyType.Text;
bool isRegex = this.chkIsRegex.Checked;

//得到被選中表的基本信息,并添加到集合中
foreach (int index in this.chkboxTableList.CheckedIndices)
{
string tabName = this.chkboxTableList.Items[index].ToString();
TableInfo tInfo = FilterInfo.initTableInfo(tabName);
if (tInfo == null)
{
continue;
}
tabList.Add(tInfo);
}

try
{
if (tabList.Count == 0) return; //沒有符合檢測的數(shù)據(jù)表

pBar1.Visible = true;
pBar1.Minimum = 1;
pBar1.Maximum = tabList.Count;
pBar1.Value = 1;
pBar1.Step = 1;

//循環(huán)過濾表中要替換的數(shù)據(jù)
foreach (TableInfo info in tabList)
{
FilterInfo.Execute(info, searchString, replaceString, kt);
pBar1.PerformStep(); //進(jìn)度條
}
}
catch (Exception ex)
{
MessageBox.Show(string.Format("異常:{0}", ex.Message), "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
finally
{
this.ExecuteFilterBtn.Enabled = true;
}

MessageBox.Show(string.Format("數(shù)據(jù)替換完畢,共有{0}行數(shù)據(jù)被修改!",total),"消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#endregion

以上就是整個(gè)大致思路,詳情可以參看源代碼。

附帶一些操作截圖,希望大家可以看的更清楚一些。

這個(gè)就是被注入的數(shù)據(jù),當(dāng)然實(shí)際的會有區(qū)別。

編寫查找內(nèi)容,并啟用正則匹配功能。

哈哈,數(shù)據(jù)終于恢復(fù)原貌!!
源程序下載地址

您可能感興趣的文章:
  • SqlServer中批量替換被插入的木馬記錄
  • sqlserver replace函數(shù) 批量替換數(shù)據(jù)庫中指定字段內(nèi)指定字符串參考方法
  • 批量替換sqlserver數(shù)據(jù)庫掛馬字段并防范sql注入攻擊的代碼
  • sqlserver 中ntext字段的批量替換(updatetext的用法)
  • SQL Server中對數(shù)據(jù)截取替換的方法詳解

標(biāo)簽:白城 怒江 赤峰 七臺河 金華 酒泉 洛陽 溫州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《sqlserver 批量數(shù)據(jù)替換助手V1.0版發(fā)布》,本文關(guān)鍵詞  sqlserver,批量,數(shù)據(jù),替換,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《sqlserver 批量數(shù)據(jù)替換助手V1.0版發(fā)布》相關(guān)的同類信息!
  • 本頁收集關(guān)于sqlserver 批量數(shù)據(jù)替換助手V1.0版發(fā)布的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 肃宁县| 保康县| 六枝特区| 鄯善县| 瑞安市| 安岳县| 思茅市| 于都县| 佳木斯市| 多伦县| 阿城市| 江永县| 韶关市| 宁城县| 五华县| 河北省| 双牌县| 长岛县| 化州市| 文登市| 仁寿县| 温泉县| 陇西县| 城固县| 农安县| 卢氏县| 儋州市| 扎鲁特旗| 蒙城县| 柯坪县| 娄底市| 石嘴山市| 太湖县| 筠连县| 万全县| 分宜县| 临夏县| 克什克腾旗| 信宜市| 福建省| 清苑县|