资源简介
直接生成c#代码,节省90% 数据库交互代码的时间!
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Configuration;
using MySql.Data.MySqlClient;
/******************************/
//欢迎加入.net mvc3交流群【198031493】
/*****************************/
public partial class _Default : System.Web.UI.Page
{
private string connStr =
“Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3};Pooling=False;charset=utf8;“ +
“MAX Pool Size=2000;Min Pool Size=1;Connection Lifetime=30;“;
private string conn = ConfigurationManager.ConnectionStrings[“conn“].ConnectionString;
private readonly string gettables = “select table_name from information_schema.tables where table_schema=‘{0}‘“;
private readonly string getflieds =
“select column_name namedata_type typeCOLUMN_TYPEcolumn_comment as infoextra as autoCHARACTER_MAXIMUM_LENGTH as len “ +
“from INFORMATION_SCHEMA.COLUMNS Where table_name =‘{0}‘ and table_schema =‘{1}‘“;
public int z = 0;
protected void Page_Load(object sender EventArgs e)
{
if (!IsPostBack)
{
txt_namespace.Text = “CiWong.“ + txt_db.Text + “.Entities“;
// BindTables();
}
}
#region DB
public DataTable GetTable(string sql)
{
conn = string.Format(connStr txt_server.Text txt_db.Text txt_uid.Text txt_pwd.Text);
DataSet ds = MySqlHelper.ExecuteDataset(conn sql);
return ds.Tables[0];
}
public void ExecuteSql(string sql)
{
MySqlHelper.ExecuteNonQuery(conn sql);
}
#endregion
#region select
private void SelectAll(StringBuilder Sb DataTable dt int count string tablename string proname)
{
var cb3list = Request[“cb3“];
if (string.IsNullOrEmpty(cb3list))
{
Page.RegisterStartupscript(“alert“ “ript>alert(‘请选择要查询的列!‘) ript>“);
return;
}
string[] arraycb3 = new string[] { };
arraycb3 = cb3list.Split(‘‘);
Sb.Append(“CREATE OR REPLACE Procedure pro_“ + proname + “_“ + tablename);
Sb.Append(“\n(\n“);
//
for (int i = 0; i < count; i++)
{
var fliedname = dt.Rows[i][“column_name“].ToString();
var fliedtype = dt.Rows[i][“data_type“].ToString();
var fliedlength = 0; // dt.Rows[i][“data_length“].ToString();
//显示选中
#region
if (arraycb3 != null && arraycb3.Count() > 0)
{
for (int j = 0; j < arraycb3.Count(); j++)
{
if (fliedname == arraycb3[j].ToString())
{
Sb.Append(“ _“ + fliedname + “ out “ + fliedtype + “(“ + fliedlength
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 47885 2012-09-15 11:55 Default.aspx.cs
目录 0 2012-04-11 09:43 bin\
文件 370176 2012-04-07 16:46 bin\MySql.Data.dll
文件 38 2012-04-11 09:43 bin\MySql.Data.dll.refresh
目录 0 2010-09-01 11:16 js\
文件 72174 2010-02-25 17:46 js\jquery-1.4.2.min.js
文件 2241 2012-04-11 11:56 web.config
文件 6738 2012-09-15 11:55 Default.aspx
评论
共有 条评论