超简单的Ms Sql数据库全库匹配内容查找

hb1122 2011-04-09 10:14:10
接手个项目,同步金蝶K3数据库指定内容至项目数据库,金蝶数据库太过繁琐,无奈写个全库查找的方法,找字段名或者字段的内容,然后点击表名,取得此表所有内容,与大家共享。。。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient ;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WorkBoardControl.FindDataBase
{
public partial class FindFromDataBase : Form
{
/// <summary>
/// 存放数据库名的表
/// </summary>
private DataTable TableDt = new DataTable();
/// <summary>
/// 存放数据表信息的表
/// </summary>
private DataTable ValueDt = new DataTable();
public FindFromDataBase()
{
InitializeComponent();
TableLoad();
DataGridViewLoad();
splitContainer2 .SplitterMoving +=new SplitterCancelEventHandler(splitContainer2_SplitterMoving);
splitContainer2.SplitterDistance = 108;
}


private void splitContainer2_SplitterMoving(object sender, SplitterCancelEventArgs e)
{
splitContainer2.SplitterDistance = 108;
}
/// <summary>
/// 数据库表初始化
/// </summary>
private void TableLoad()
{
TableDt.Columns.Add(new DataColumn ("name",typeof (String)));
}


/// <summary>
/// 表格视图的初始化
/// </summary>
private void DataGridViewLoad()
{
FindTable.AutoGenerateColumns = false;
FindTable.DataSource = TableDt;
FindTable.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
FindTable.RowPostPaint +=new DataGridViewRowPostPaintEventHandler(DGVHelp.RowPostPoint );
FindTable.CellMouseClick +=new DataGridViewCellMouseEventHandler(FindTable_CellMouseClick);
FindTable.Columns.Add(DGVHelp.BuildTextBoxColumn("name", "数据表名", "name",
typeof(String), 150, true, DataGridViewColumnSortMode.Automatic , DataGridViewContentAlignment.MiddleCenter));

ShowInfo.RowPostPaint +=new DataGridViewRowPostPaintEventHandler(DGVHelp.RowPostPoint );
ShowInfo.DataError +=new DataGridViewDataErrorEventHandler(ShowInfo_DataError);
}

private void ShowInfo_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
}
/// <summary>
/// 单元格点击后
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FindTable_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (FindTable.SelectedRows.Count > 0)
{
//有内容,才进行下一步
DataRowView tmpView = (DataRowView)FindTable.SelectedRows[0].DataBoundItem;

SqlConnection newConn = BuildConnection ();
if (newConn != null)
{
SqlDataAdapter newDa = new SqlDataAdapter("select * from " + tmpView["name"].ToString() + "", newConn);
if (ValueDt.Columns.Count > 0)
{
//有列,则清除
ValueDt = new DataTable();
}
newDa.Fill(ValueDt);
ShowInfo.DataSource = ValueDt ;
}
else
{
MessageBox.Show("连接信息不足");
}


}
}

/// <summary>
/// 用当前的输入,来生成连接
/// </summary>
/// <returns></returns>
private SqlConnection BuildConnection()
{
if (DataSourceName.Text.Length > 0 && Port.Text.Length > 0 && UserName.Text.Length > 0 && Pwd.Text.Length > 0 && DataBaseName.Text.Length > 0)
{
//数据有效
try
{
return new SqlConnection("server=" + DataSourceName .Text + "," + Port.Text + ";database=" + DataBaseName .Text + ";uid=" + UserName.Text + ";pwd=" + Pwd.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return null;
}
}
else
{
return null;
}
}
/// <summary>
/// 找字段
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

private void button1_Click(object sender, System.EventArgs e)
{
if (FieldName.Text.Length > 0)
{
try
{
SqlConnection newConn = BuildConnection();
if (newConn != null)
{
//执行
SqlDataAdapter newDa = new SqlDataAdapter(
"select name from sysobjects where id in (SELECT id " +
"FROM syscolumns where name = '" + FieldName.Text + "') and xtype = 'U'", newConn);
if (TableDt.Rows.Count > 0)
{
TableDt.Rows.Clear();
}
newDa.Fill(TableDt);
}
else
{
MessageBox.Show("连接信息不足");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
else
{
MessageBox.Show("请输入字段名先");
}
}

/// <summary>
/// 找内容
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, System.EventArgs e)
{
if (ValueInfo.Text.Length > 0)
{
try
{
//开始霸道的找内容中
SqlConnection newConn = BuildConnection();
SqlConnection findConn = BuildConnection();
if (newConn != null)
{
//可用
String FindStr = ValueInfo.Text;

//清除现在表中内容
if (TableDt.Rows.Count > 0)
{
TableDt.Rows.Clear();
}
using (SqlConnection TopConn = newConn)
{
TopConn.Open();
findConn.Open();
using (SqlCommand TopCmd = new SqlCommand(
"select sysobjects.name,syscolumns.name as columnname,syscolumns.xtype as xtype from sysobjects inner join " +
" syscolumns on sysobjects.id = syscolumns.id where syscolumns.xtype in " +
" (" + GetTypeFil(FindStr) + " ) and sysobjects.xtype = 'U' " +
" order by sysobjects.name", TopConn))
{
using (SqlDataReader TopRead = TopCmd.ExecuteReader())
{
String TableName = "";
String FindFil = "";
while (TopRead.Read())
{
if (TableName != TopRead["name"].ToString())
{
//表名不同时
//查找
if (TableName != "")
{
FindValue(findConn, "[" + TableName + "]", FindFil);
}
TableName = TopRead["name"].ToString();
FindFil = BuildFilStr ( TopRead["columnname"].ToString(), FindStr,TopRead ["xtype"].ToString ());
}
else
{
FindFil += " or " + BuildFilStr(TopRead["columnname"].ToString(), FindStr, TopRead["xtype"].ToString ());
}

}

if (TableName != "")
{
FindValue(findConn, TableName, FindFil);
}
}
}
findConn .Close();
}
MessageBox.Show("完成查找");
}
else
{
MessageBox.Show("连接信息不全");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
else
{
MessageBox.Show("请输入待查找的内容先");
}
}
...全文
224 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
myrroom 2011-04-09
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 hb1122 的回复:]
引用 4 楼 myrroom 的回复:
你不能回复了吧,我帮你推一把


己回复完毕。。。。。。
[/Quote]
嘿嘿
duanzhi1984 2011-04-09
  • 打赏
  • 举报
回复
这样也太烦琐了把
hb1122 2011-04-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 myrroom 的回复:]
你不能回复了吧,我帮你推一把
[/Quote]

己回复完毕。。。。。。
myrroom 2011-04-09
  • 打赏
  • 举报
回复
你不能回复了吧,我帮你推一把
hb1122 2011-04-09
  • 打赏
  • 举报
回复
// 
// button2
//
this.button2.Location = new System.Drawing.Point(242, 76);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(92, 23);
this.button2.TabIndex = 16;
this.button2.Text = "找数据内容";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.groupControl1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.groupControl2);
this.splitContainer1.Size = new System.Drawing.Size(994, 433);
this.splitContainer1.SplitterDistance = 240;
this.splitContainer1.TabIndex = 17;
//
// groupControl1
//
this.groupControl1.Controls.Add(this.FindTable);
this.groupControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupControl1.Location = new System.Drawing.Point(0, 0);
this.groupControl1.Name = "groupControl1";
this.groupControl1.Size = new System.Drawing.Size(240, 433);
this.groupControl1.TabIndex = 0;
this.groupControl1.Text = "数据库";
//
// FindTable
//
this.FindTable.AllowUserToAddRows = false;
this.FindTable.AllowUserToDeleteRows = false;
this.FindTable.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.FindTable.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.FindTable.Dock = System.Windows.Forms.DockStyle.Fill;
this.FindTable.Location = new System.Drawing.Point(2, 21);
this.FindTable.Name = "FindTable";
this.FindTable.ReadOnly = true;
this.FindTable.RowTemplate.Height = 23;
this.FindTable.Size = new System.Drawing.Size(236, 410);
this.FindTable.TabIndex = 0;
//
// groupControl2
//
this.groupControl2.Controls.Add(this.ShowInfo);
this.groupControl2.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupControl2.Location = new System.Drawing.Point(0, 0);
this.groupControl2.Name = "groupControl2";
this.groupControl2.Size = new System.Drawing.Size(750, 433);
this.groupControl2.TabIndex = 0;
this.groupControl2.Text = "内容";
//
// ShowInfo
//
this.ShowInfo.AllowUserToAddRows = false;
this.ShowInfo.AllowUserToDeleteRows = false;
this.ShowInfo.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.ShowInfo.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.ShowInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.ShowInfo.Location = new System.Drawing.Point(2, 21);
this.ShowInfo.Name = "ShowInfo";
this.ShowInfo.ReadOnly = true;
this.ShowInfo.RowTemplate.Height = 23;
this.ShowInfo.Size = new System.Drawing.Size(746, 410);
this.ShowInfo.TabIndex = 0;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.label1);
this.splitContainer2.Panel1.Controls.Add(this.button2);
this.splitContainer2.Panel1.Controls.Add(this.label2);
this.splitContainer2.Panel1.Controls.Add(this.button1);
this.splitContainer2.Panel1.Controls.Add(this.label3);
this.splitContainer2.Panel1.Controls.Add(this.label7);
this.splitContainer2.Panel1.Controls.Add(this.label4);
this.splitContainer2.Panel1.Controls.Add(this.label5);
this.splitContainer2.Panel1.Controls.Add(this.label6);
this.splitContainer2.Panel1.Controls.Add(this.ValueInfo);
this.splitContainer2.Panel1.Controls.Add(this.DataSourceName);
this.splitContainer2.Panel1.Controls.Add(this.FieldName);
this.splitContainer2.Panel1.Controls.Add(this.Port);
this.splitContainer2.Panel1.Controls.Add(this.DataBaseName);
this.splitContainer2.Panel1.Controls.Add(this.UserName);
this.splitContainer2.Panel1.Controls.Add(this.Pwd);
this.splitContainer2.Panel1MinSize = 108;
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.splitContainer1);
this.splitContainer2.Size = new System.Drawing.Size(994, 545);
this.splitContainer2.SplitterDistance = 108;
this.splitContainer2.TabIndex = 18;
//
// FindFromDataBase
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(994, 545);
this.Controls.Add(this.splitContainer2);
this.Name = "FindFromDataBase";
this.Text = "FindFromDataBase";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).EndInit();
this.groupControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.FindTable)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.groupControl2)).EndInit();
this.groupControl2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.ShowInfo)).EndInit();
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel1.PerformLayout();
this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.ResumeLayout(false);
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox DataSourceName;
private System.Windows.Forms.TextBox Port;
private System.Windows.Forms.TextBox UserName;
private System.Windows.Forms.TextBox Pwd;
private System.Windows.Forms.TextBox DataBaseName;
private System.Windows.Forms.TextBox FieldName;
private System.Windows.Forms.TextBox ValueInfo;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.SplitContainer splitContainer1;
private DevExpress.XtraEditors.GroupControl groupControl1;
private DevExpress.XtraEditors.GroupControl groupControl2;
private System.Windows.Forms.DataGridView FindTable;
private System.Windows.Forms.DataGridView ShowInfo;
private System.Windows.Forms.SplitContainer splitContainer2;
}
}
hb1122 2011-04-09
  • 打赏
  • 举报
回复
namespace WorkBoardControl.FindDataBase
{
partial class FindFromDataBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.DataSourceName = new System.Windows.Forms.TextBox();
this.Port = new System.Windows.Forms.TextBox();
this.UserName = new System.Windows.Forms.TextBox();
this.Pwd = new System.Windows.Forms.TextBox();
this.DataBaseName = new System.Windows.Forms.TextBox();
this.FieldName = new System.Windows.Forms.TextBox();
this.ValueInfo = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
this.FindTable = new System.Windows.Forms.DataGridView();
this.groupControl2 = new DevExpress.XtraEditors.GroupControl();
this.ShowInfo = new System.Windows.Forms.DataGridView();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
this.groupControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.FindTable)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.groupControl2)).BeginInit();
this.groupControl2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ShowInfo)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "数据源";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(435, 13);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 1;
this.label2.Text = "密码";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(562, 13);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 12);
this.label3.TabIndex = 2;
this.label3.Text = "数据库";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(242, 13);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(29, 12);
this.label4.TabIndex = 3;
this.label4.Text = "端口";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(323, 13);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(41, 12);
this.label6.TabIndex = 5;
this.label6.Text = "用户名";
//
// DataSourceName
//
this.DataSourceName.ImeMode = System.Windows.Forms.ImeMode.Off;
this.DataSourceName.Location = new System.Drawing.Point(59, 10);
this.DataSourceName.Name = "DataSourceName";
this.DataSourceName.Size = new System.Drawing.Size(177, 21);
this.DataSourceName.TabIndex = 6;
this.DataSourceName.Text = "192.168.100.230";
//
// Port
//
this.Port.Location = new System.Drawing.Point(277, 10);
this.Port.Name = "Port";
this.Port.Size = new System.Drawing.Size(40, 21);
this.Port.TabIndex = 7;
this.Port.Text = "1433";
//
// UserName
//
this.UserName.ImeMode = System.Windows.Forms.ImeMode.Off;
this.UserName.Location = new System.Drawing.Point(370, 10);
this.UserName.Name = "UserName";
this.UserName.Size = new System.Drawing.Size(59, 21);
this.UserName.TabIndex = 8;
this.UserName.Text = "de";
//
// Pwd
//
this.Pwd.ImeMode = System.Windows.Forms.ImeMode.Off;
this.Pwd.Location = new System.Drawing.Point(470, 10);
this.Pwd.Name = "Pwd";
this.Pwd.Size = new System.Drawing.Size(86, 21);
this.Pwd.TabIndex = 9;
this.Pwd.Text = "";
//
// DataBaseName
//
this.DataBaseName.ImeMode = System.Windows.Forms.ImeMode.Off;
this.DataBaseName.Location = new System.Drawing.Point(609, 10);
this.DataBaseName.Name = "DataBaseName";
this.DataBaseName.Size = new System.Drawing.Size(137, 21);
this.DataBaseName.TabIndex = 10;
this.DataBaseName.Text = "AIS20081230134105";
//
// FieldName
//
this.FieldName.ImeMode = System.Windows.Forms.ImeMode.Off;
this.FieldName.Location = new System.Drawing.Point(59, 47);
this.FieldName.Name = "FieldName";
this.FieldName.Size = new System.Drawing.Size(177, 21);
this.FieldName.TabIndex = 11;
//
// ValueInfo
//
this.ValueInfo.ImeMode = System.Windows.Forms.ImeMode.Off;
this.ValueInfo.Location = new System.Drawing.Point(59, 78);
this.ValueInfo.Name = "ValueInfo";
this.ValueInfo.Size = new System.Drawing.Size(177, 21);
this.ValueInfo.TabIndex = 12;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 47);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(41, 12);
this.label5.TabIndex = 13;
this.label5.Text = "字段名";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 78);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(41, 12);
this.label7.TabIndex = 14;
this.label7.Text = "内 容";
//
// button1
//
this.button1.Location = new System.Drawing.Point(242, 45);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(92, 23);
this.button1.TabIndex = 15;
this.button1.Text = "找字段名";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
hb1122 2011-04-09
  • 打赏
  • 举报
回复
        /// <summary>
/// 根据字段类型,生成特定的条件语句
/// </summary>
/// <param name="ColumnName"></param>
/// <param name="FindStr"></param>
/// <param name="type"></param>
/// <returns></returns>
private String BuildFilStr(String ColumnName, String FindStr, String type)
{
switch (type)
{
#region 数字
//tinyint
case "48":
return " [" + ColumnName + "] = " + FindStr ;
//smallint
case "52":
return " [" + ColumnName + "] = " + FindStr;
//int
case "56":
return " [" + ColumnName + "] = " + FindStr;
//real
case "59":
return " [" + ColumnName + "] = " + FindStr;
//float
case "62":
return " [" + ColumnName + "] = " + FindStr;
//decimal
case "106":
return " [" + ColumnName + "] = " + FindStr;
//numeric
case "108":
return " [" + ColumnName + "] = " + FindStr;
//bigint
case "127":
return " [" + ColumnName + "] = " + FindStr;
#endregion
#region 字符
//varchar
case "167":
return " [" + ColumnName + "] = '" + FindStr + "'";
//char
case "175":
return " [" + ColumnName + "] = '" + FindStr + "'";
//nvarchar
case "231":
return " [" + ColumnName + "] = '" + FindStr + "'";
//nchar
case "239":
return " [" + ColumnName + "] = '" + FindStr + "'";
#endregion
default :
return " [" + ColumnName + "] = '" + FindStr + "'";

}

}
/// <summary>
/// 查找表中是否
/// </summary>
/// <param name="Conn"></param>
/// <param name="TableName"></param>
/// <param name="FieldFil"></param>
/// <returns></returns>
private void FindValue(SqlConnection Conn, String TableName, String FieldFil)
{
try
{

using (SqlCommand FindCmd = new SqlCommand("select top 1 * from " + TableName + " where " + FieldFil, Conn ))
{
using (SqlDataReader FindRead = FindCmd.ExecuteReader())
{
if (FindRead.Read())
{
DataRow newRow = TableDt.NewRow();
newRow["name"] = TableName;
TableDt.Rows.Add(newRow);
}
}
}

}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString()+ "\n tablename:" + TableName + "\n fil:" + FieldFil );
}
finally
{
System.Threading.Thread.Sleep(50);
}
}

private String GetTypeFil(String Str)
{
try
{
//转数字成功,则在文本和数字中找,不然只在文本中找
Decimal value = Decimal.Parse(Str);
return " 48, 52, 56, 59, 62, 106, 108, 127, 167, 175, 231, 231, 239";
}
catch
{
//转数字失败,确定是文本
return " 167, 175, 231, 239 ";
}

}

/*
SQL中的系统字段表中的字段类型 xtype 类型
34 image
35 text
36 uniqueidentifier
48 tinyint
52 smallint
56 int
58 smalldatetime
59 real
60 money
61 datetime
62 float
98 sql_variant
99 ntext
104 bit
106 decimal
108 numeric
122 smallmoney
127 bigint
165 varbinary
167 varchar
173 binary
175 char
189 timestamp
231 sysname
231 nvarchar
239 nchar
*/
}
}

hb1122 2011-04-09
  • 打赏
  • 举报
回复
没办法呀,不知道神马内容在神马表里放着。。。

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧