知识大全 asp.net管理mysql数据库的小工具.
Posted 数据库
篇首语:恢弘志士之气,不宜妄自菲薄。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 asp.net管理mysql数据库的小工具.相关的知识,希望对你有一定的参考价值。
在 中 可以通过MySQL Data dll来操作mysql数据库 写法跟操作SQL数据库类似 下面是相关的例子 一 打开mysql数据库 MySqlConnection DBConn = new MySqlConnection(); string connString = Host= ;UserName=root;PassWord=root;Database=test;Port= ;CharSet=utf ;Allow Zero Datetime=true ; DBConn ConnectionString = connString; DBConn Open(); 二 执行sql命令 string sqlstr= select * from test ; MySqlCommand mand = new MySqlCommand(sqlstr DBConn); mand ExecuteNonQuery(); 从上面可以看出 用法跟操作SQL数据库的SqlConnection SqlCommand非常相似 下面我这里有一个完整的例子来实现对mysql数据库进行管理 包括浏览表结构和数据 查询 修改 插入 删除数据 导出数据和表结构等 供大家参考和互相学习 代码写得不规范 还请大家指正 <%@ Page Language= C# %> <%@ Import Namespace= System Data %> <%@ Import Namespace= System IO %> <%@ Import Namespace= System Text %> <%@ Import Namespace= MySql Data MySqlClient %> <!DOCTYPE PUBLIC //W C//DTD XHTML Transitional//EN transitional dtd > < xmlns= > <head runat= server > <title> MYSQL Manager (DoNet)</title> <style type= text/CSS > body tdfont: px Arial Tahoma;line height: px; inputfont: px Arial Tahoma;background:#fff;border: px solid # ;padding: px;height: px; areafont: px Courier New Monospace;background:#fff;border: px solid # ;padding: px; bt border color:#b b b ;background:# d d d;color:#ffffff;font: px Arial Tahoma;height: px; a color: # f;text decoration:underline; a:hovercolor: #f ;text decoration:none; alt tdborder top: px solid #fff;border bottom: px solid #ddd;background:#f f f ;padding: px px px px; alt tdborder top: px solid #fff;border bottom: px solid #ddd;background:#f f f ;padding: px px px px; focus tdborder top: px solid #fff;border bottom: px solid #ddd;background:#ffffaa;padding: px px px px; head tdborder top: px solid #fff;border bottom: px solid #ddd;background:#e e e ;padding: px px px px;font weight:bold; head td spanfont weight:normal; formmargin: ;padding: ; h margin: ;padding: ;height: px;line height: px;font size: px;color:# B F; limargin: ;color:# ;line height: px;height: px; utext decoration: none;color:# ;float:left;display:block;width: px;margin right: px; p div line height: %; </style> <script runat= server > PRivate string m_Admin = ; MySqlConnection DBConn = new MySqlConnection(); private string connString = string Empty; DataTable tblsDt = null; int tblRowsCount = ; int tblsCount = ; float tblDbSize = f; private bool OpenData() if (session[ dbhost ] != null && Session[ dbuser ] != null && Session[ dbpass ] != null && Session[ dbname ] != null && Session[ dbport ] != null && Session[ charset ] != null && Session[ dbhost ] ToString() Trim() != string Empty && Session[ dbuser ] ToString() Trim() != string Empty && Session[ dbpass ] ToString() Trim() != string Empty && Session[ dbname ] ToString() Trim() != string Empty && Session[ dbport ] ToString() Trim() != string Empty && Session[ charset ] ToString() Trim() != string Empty ) connString = string Format( Host = ; UserName = ; Password = ; Database = ; Port = ;CharSet= ;Allow Zero Datetime=true Session[ dbhost ] ToString() Trim() Session[ dbuser ] ToString() Trim() Session[ dbpass ] ToString() Trim() Session[ dbname ] ToString() Trim() Session[ dbport ] ToString() Trim() Session[ charset ] ToString() Trim() ); if (connString != string Empty && DBConn State != ConnectionState Open) DBConn ConnectionString = connString; try DBConn Open(); catch (Exception ex) Response Write( 数据库连接失败 请检查连接字符串! + ex Message); return false; return true; return false; private void CloseData() DBConn Close(); private string FindPK(string tablename) string PKName = string Empty; DataTable dt = RunTable( SHOW KEYS FROM + tablename); for (int i = ; i < dt Rows Count; i++) if (dt Rows[i][ Key_name ] ToString() ToUpper() == PRIMARY ) PKName = dt Rows[i][ Column_name ] ToString(); break; return PKName; private DataTable RunTable(string sqlstr) DataTable data = new DataTable(); MySqlDataAdapter da = new MySqlDataAdapter(); try OpenData(); da SelectCommand = new MySqlCommand(sqlstr DBConn); da Fill(data); catch (Exception ex) Response Write( 执行SQL错误 + ex Message + <br>SQL: + sqlstr); Response End(); finally da Dispose(); DBConn Close(); return data; private void ShowAllTable() string sqlstr = SHOW TABLE STATUS ; tblsDt = RunTable(sqlstr); PanTables Visible = true; tblRun Visible = true; private DataTable TableColumn(string tablename) return RunTable( SHOW COLUMNS FROM + tablename); private DataTable TableStructure(string tablename) return RunTable( SHOW FIELDS FROM + tablename); private bool isAuto_increment(string tblname string columnname) DataTable table = TableStructure(tblname); bool boolIs = false; for (int i = ; i < table Rows Count; i++) if (table Rows[i][ Field ] ToString() ToUpper() == columnname ToUpper()) if (table Rows[i][ Extra ] ToString() ToLower() == auto_increment ) boolIs = true; break; return boolIs; private void ShowTableData() PanShow Visible = true; tblRun Visible = true; sql_query Value = SELECT * FROM + Request QueryString[ tblname ] + LIMIT ; private void ShowEditeData() PanelEdit Visible = true; tblRun Visible = true; sql_query Value = SELECT * FROM + Request QueryString[ tblname ] + LIMIT ; private void Structure() PanelStructure Visible = true; tblRun Visible = true; sql_query Value = SELECT * FROM + Request QueryString[ tblname ] + LIMIT ; private void InsertData() PanelInsert Visible = true; tblRun Visible = true; sql_query Value = SELECT * FROM + Request QueryString[ tblname ] + LIMIT ; private void ExportSucc() ShowAllTable(); if (Session[ exportinfo ] != null && Session[ exportinfo ] ToString()!=string Empty) lblExport Text = Session[ exportinfo ] ToString(); divSucc Visible = true; Session[ exportinfo ] = null; protected void Page_Load(object sender EventArgs e) if (Session[ login ] == null || Session[ login ] ToString() Length < ) PanelLogin Visible = true; else PanelSucc Visible = true; if (!Page IsPostBack) txtpassword Attributes Add( onkeydown SubmitKeyClick( btnLogin ); ); InitFrm(); if (OpenData()) ShowDBs(); if (Request QueryString[ action ] != null) switch (Request QueryString[ action ] ToString()) case show : ShowTableData(); break; case edit : ShowEditeData(); break; case deldata : deldataData(); break; case insert : InsertData(); break; case structure : Structure(); break; case droptable : DropTable(); break; case exportsucc : ExportSucc(); break; else ShowAllTable(); ShowConnForm(); private void InitFrm() if (Session[ dbhost ] != null) dbhost Value = Session[ dbhost ] ToString(); if (Session[ dbuser ] != null) dbuser Value = Session[ dbuser ] ToString(); if (Session[ dbpass ] != null) dbpass Value = Session[ dbpass ] ToString(); if (Session[ dbname ] != null) dbname Value = Session[ dbname ] ToString(); if (Session[ dbport ] != null) dbport Value = Session[ dbport ] ToString(); if (Session[ charset ] != null) charset SelectedIndex = ; charset Items FindByValue(Session[ charset ] ToString()) Selected = true; //value= <%=Server MapPath( MySQL sql ) %> txtSavePath Value = Server MapPath(Request ServerVariables[ HTTP_HOST ] Replace( ) Replace( : ) + MySQL sql ); private void ShowConnForm() PanFrm Visible = true; protected void connect_ServerClick(object sender EventArgs e) connString = string Format( Host = ; UserName = ; Password = ; Database = ; Port = ;CharSet= ;Allow Zero Datetime=true dbhost Value Trim() dbuser Value Trim() dbpass Value Trim() dbname Value Trim() dbport Value Trim() charset Value Trim() ); Session[ dbhost ] = dbhost Value Trim(); Session[ dbuser ] = dbuser Value Trim(); Session[ dbpass ] = dbpass Value Trim(); Session[ dbname ] = dbname Value Trim(); Session[ dbport ] = dbport Value Trim(); Session[ charset ] = charset Value Trim(); if (OpenData()) ShowDBs(); //ShowAllTable(); private string showSize(float size) if (size > * ) return Math Round(size / ( * ) ) + M ; else if (size > ) return Math Round(size / ) + K ; else return size + B ; protected void Submit _ServerClick(object sender EventArgs e) if (sql_query Value Trim() != string Empty) if (OpenData()) PanelQuery Visible = true; else Response Redirect(Request ServerVariables[ HTTP_REFERER ] + true); protected void Submit _ServerClick(object sender EventArgs e) StringBuilder sb = new StringBuilder(); string tblname = Request QueryString[ tblname ] Trim(); DataTable dt = TableColumn(tblname); sb Append( update ` + tblname + ` set ); for (int i = ; i < dt Rows Count; i++) if (i != ) sb Append( ); sb Append( ` + dt Rows[i][ ] ToString() Trim() + `= ); string columntype = dt Rows[i][ ] ToString() Trim(); bool mustAdd = false; if (columntype IndexOf( char ) != || columntype IndexOf( datetime ) != || columntype IndexOf( string ) != ) mustAdd = true; if (mustAdd) sb Append( ); sb Append(Request Form[ insertsql_ + dt Rows[i][ ] ToString() Trim() Replace( )]); if (mustAdd) sb Append( ); sb Append( where + Request QueryString[ pk ] ToString() + = + Request QueryString[ v ] ToString() + ); string sql = sb ToString(); RunTable(sql); Response Redirect(Request ServerVariables[ Script_Name ] + ?action=show&tblname= + tblname true); private void deldataData() StringBuilder sb = new StringBuilder(); string tblname = Request QueryString[ tblname ] Trim(); sb Append( delete from ` + tblname + ` ); sb Append( where + Request QueryString[ pk ] ToString() + = + Request QueryString[ v ] ToString() + ); string sql = sb ToString(); RunTable(sql); Response Redirect(Request ServerVariables[ Script_Name ] + ?action=show&tblname= + tblname true); private void ShowDBs() string sql = SHOW DATABASES ; seldbname DataSource = new DataTable(); seldbname DataBind(); ListItem item = new ListItem( 选择数据库 ); seldbname Items Add(item); DataTable dt = RunTable(sql); for (int i = ; i < dt Rows Count; i++) string dname = dt Rows[i][ ] ToString(); if (dname != information_schema ) seldbname Items Add(new ListItem(dname dname)); private void DropTable() StringBuilder sb = new StringBuilder(); string tblname = Request QueryString[ tblname ] Trim(); sb Append( drop table ` + tblname + ` ); string sql = sb ToString(); RunTable(sql); Response Redirect(Request ServerVariables[ Script_Name ] true); protected void btninsert_ServerClick(object sender EventArgs e) StringBuilder sb = new StringBuilder(); string tblname = Request QueryString[ tblname ] Trim(); DataTable dt = TableColumn(tblname); sb Append( insert into ` + tblname + ` ( ); int m = ; for (int i = ; i < dt Rows Count; i++) if (!isAuto_increment(tblname dt Rows[i][ ] ToString())) m++; if (m != ) sb Append( ); sb Append( ` + dt Rows[i][ ] ToString() Trim() + ` ); sb Append( ) values ( ); m = ; for (int i = ; i < dt Rows Count; i++) if (!isAuto_increment(tblname dt Rows[i][ ] ToString())) m++; if (m != ) sb Append( ); string columntype = dt Rows[i][ ] ToString() Trim(); bool mustAdd = false; if (columntype IndexOf( char ) != || columntype IndexOf( datetime ) != || columntype IndexOf( string ) != ) mustAdd = true; if (mustAdd) sb Append( ); sb Append(Request Form[ insertsql_ + dt Rows[i][ ] ToString() Trim() Replace( )]); if (mustAdd) sb Append( ); sb Append( ) ); string sql = sb ToString(); Response Write(sql); RunTable(sql); Response Redirect(Request ServerVariables[ Script_Name ] + ?action=show&tblname= + tblname true); protected void seldbname_SelectedIndexChanged(object sender EventArgs e) Session[ dbname ] = seldbname Items[seldbname SelectedIndex] Value ToString() Trim(); Response Redirect(Request ServerVariables[ Script_Name ] + true); protected void btnLogin_Click(object sender EventArgs e) if (txtpassword Value Trim() == m_Admin) Session[ login ] = login ; Response Redirect(Request ServerVariables[ Script_Name ] + true); //备份数据库 private string sqldumptable(string tblname) StringBuilder sb = new StringBuilder(); sb Append( DROP TABLE IF EXISTS ` + tblname + `;\\n ); sb Append( CREATE TABLE + tblname + (\\n ); int firstfield= ; DataTable dtFields = RunTable( SHOW FIELDS FROM + tblname + ); for (int i = k = dtFields Rows Count; i < k; i++) if (firstfield != ) sb Append( \\n ); else firstfield = ; sb Append( ` +dtFields Rows[i][ Field ] ToString() + ` + dtFields Rows[i][ Type ] ToString()); if (dtFields Rows[i][ Default ] != null && dtFields Rows[i][ Default ] ToString() != string Empty) sb Append( DEFAULT + dtFields Rows[i][ Default ]); if (dtFields Rows[i][ Null ] ToString() ToUpper() != YES ) sb Append( NOT NULL ); if (dtFields Rows[i][ Extra ] ToString() != ) sb Append(dtFields Rows[i][ Extra ] ToString()); dtFields Dispose(); DataTable dtKeys = RunTable( SHOW KEYS FROM + tblname + ); bool haskey = false; string PRIMARY = string Empty; for (int i = k = dtKeys Rows Count; i < k; i++) string kname = dtKeys Rows[i][ Key_name ] ToString(); if (kname ToUpper() != PRIMARY && dtKeys Rows[i][ Non_unique ] ToString() Trim() == ) kname = UNIQUE| + kname + ; if (kname ToUpper() == PRIMARY ) if (haskey) PRIMARY = PRIMARY + ; else haskey = true; PRIMARY = PRIMARY + dtKeys Rows[i][ Column_name ]; else sb Append( \\n ); if (kname Length> && kname Substring( ) ToUpper() == UNIQUE ) kname = kname Substring( ); sb Append( KEY + kname + ( + dtKeys Rows[i][ Column_name ] + ) ); sb Append( \\n PRIMARY KEY ( + PRIMARY + ) ); sb Append( \\n);\\n\\n ); dtKeys Dispose(); DataTable dtRows = RunTable( SELECT * FROM + tblname); for (int i = k = dtRows Rows Count; i < k; i++) sb Append( INSERT INTO + tblname + VALUES( ); int fieldcounter = ; firstfield = ; for (int m = n = dtRows Columns Count; m < n; m++) if (firstfield != ) sb Append( ); else firstfield = ; if (dtRows Rows[i][m] == null) sb Append( NULL ); else sb Append( + dtRows Rows[i][m] ToString() Trim() Replace( ) + ); sb Append( );\\n ); return sb ToString(); private void SavetoFile(string info string filepath) FileStream stream = new FileStream(filepath FileMode Create Fileaccess Write FileShare Delete | FileShare ReadWrite); StreamWriter writer = new StreamWriter(stream); writer WriteLine(info); writer Close(); stream Close(); stream Dispose(); writer Dispose(); private void ExportDown(string info) string filename = Request ServerVariables[ HTTP_HOST ] + MySQL sql ; Response ContentType = application/unknown ; Response AddHeader( Content Disposition attachment;filename= + filename); Response Write(info); Response End(); protected void btnExport_ServerClick(object sender EventArgs e) string tables = string Empty; StringBuilder infosb = new StringBuilder(); if(Request Form[ tables ]!=null) tables = Request Form[ tables ] ToString() Trim(); string[] tableArr = tables Split( ); for (int i = k = tableArr Length; i < k; i++) if (tableArr[i] Trim() != string Empty) infosb Append(sqldumptable(tableArr[i] Trim()) + \\n\\n\\n\\n\\n\\n ); if (cbSaveFile Checked) SavetoFile(infosb ToString() txtSavePath Value Trim()); Session[ exportinfo ] = <a href=\\ + txtSavePath Value Replace(Server MapPath( now txt ) Replace( now txt ) ) + \\ target=\\ _blank\\ > + txtSavePath Value + </a> ; Response Redirect(Request ServerVariables[ Script_Name ] + ?action=exportsucc true); else ExportDown(infosb ToString()); </script> <script language= javascript > function SubmitKeyClick(button) if (event keyCode == ) event keyCode= ; event returnValue = false; document getElementById( btnLogin ) click(); function CheckAll(form) for(var i= ;i<form elements length;i++) var e = form elements[i]; if (e name != call &&e name== tables ) e checked = form call checked; </script> </head> <body> <form id= form runat= server > <div> <asp:Panel ID= PanelLogin runat= server Visible= false DefaultButton= btnLogin > <h > MYSQL Manager (DoNet) »</h > <span >密码: </span> <input name= password type= password size= id= txtpassword runat= server > <asp:Button ID= btnLogin runat= server Text= 登录 OnClick= btnLogin_Click /> </asp:Panel> <asp:Panel ID= PanelSucc runat= server Visible= false > <asp:Panel ID= PanFrm runat= server Visible= false > <h > MYSQL Manager (DoNet) »</h > <input id= action type= hidden name= action value= sqladmin runat= server /> <p> 主机IP: <input class= input name= dbhost id= dbhost value= localhost type= text size= runat= server /> : <input class= input name= dbport id= dbport value= type= text size= runat= server /> 用户名: <input class= input name= dbuser id= dbuser value= root type= text size= runat= server /> 密码: <input class= input name= dbpass id= dbpass type= text size= runat= server /> <span > 数据库名: <input class= input name= dbname id= dbname type= text size= runat= server /> </span> 数据库编码: <select class= input id= charset name= charset runat= server > <option value= selected>Default</option> <option value= gbk >GBK</option> <option value= big >Big </option> <option value= utf >UTF </option> <option value= latin >Latin </option> </select> <input class= bt name= connect id= connect value= 连 接 type= submit size= onserverclick= connect_ServerClick runat= server /> </p> <p> 选择数据库 <asp:DropDownList id= seldbname runat= server CssClass= input AutoPostBack= True OnSelectedIndexChanged= seldbname_SelectedIndexChanged > <asp:ListItem Text= 选择数据库 ></asp:ListItem> </asp:DropDownList> </p> </asp:Panel> <div> <%if (Session[ dbname ] != null && Session[ dbname ] ToString() != string Empty) %> 当前数据库: <a > <%=dbname Value %> </a> <% %> <%if (Request QueryString[ tblname ] != null) %> | 当前表: <a ?action=show&tblname=<%=Request QueryString[ tblname ] %> > <%=Request QueryString[ tblname ] %> </a>[ <a ?action=insert&tblname=<%=Request QueryString[ tblname ] %> >添加</a> | <a ?action=structure&tblname=<%=Request QueryString[ tblname ] %> >结构</a> | <a ?action=droptable&tblname=<%=Request QueryString[ tblname ] %> onclick= return confirm( 确定删除表 <%=Request QueryString[ tblname ] %> ? ) > 删除表</a> ] <% %> </div> <div runat= server visible= false id= divSucc > 数据库已经导出为<asp:Label ID= lblExport runat= server > </asp:Label> </div> <table width= border= cellpadding= cellspacing= runat= server id= tblRun visible= false > <tr> <td colspan= > 运行SQL语句 :</td> </tr> <tr> <td> <textarea name= sql_query class= area id= sql_query runat= server ></textarea></td> <td > <input class= bt name= submit type= submit value= Query id= Submit onserverclick= Submit _ServerClick runat= server /></td> </tr> </table> <asp:Panel ID= PanelQuery runat= server Visible= false EnableViewState= false > <% DataTable dColumn = RunTable(sql_query Value); %> <table border= cellpadding= cellspacing= > <tr class= head > <% for (int i = ; i < dColumn Columns Count; i++) %> <td nowrap> <%= dColumn Columns[i] Caption%> </td> <% %> </tr> <% DataTable dData = dColumn; for (int i = ; i < dData Rows Count; i++) %> <tr class= alt<%=i% == ? : %> onmouSEOver= this className= focus ; onmouseout= this className= alt<%=i% == ? : %> ; > <% for (int j = ; j < dData Columns Count; j++) %> <td nowrap> <%= dData Rows[i][j] ToString()%> </td> <% %> </tr> <% %> </table> <br /> <b>运行的SQL :</b> <%=sql_query Value%> </asp:Panel> <asp:Panel ID= PanTables runat= server Visible= false EnableViewState= false > <table border= cellpadding= cellspacing= width= % align= center > <tr class= head > <td width= % align= center ><input name= call value= on type= checkbox onClick= CheckAll(this form) /></td> <td> Name</td> <td> Rows</td> <td> Data_length</td> <td> Create_time</td> <td> Update_time</td> </tr> <% for (int i = ; i < tblsDt Rows Count; i++) tblRowsCount += int Parse(tblsDt Rows[i][ Rows ] ToString()); tblsCount++; tblDbSize += float Parse(tblsDt Rows[i][ Data_length ] ToString()); %> <tr class= alt<%=i% == ? : %> > <td align= center width= % > <input type= checkbox name= tables value= <%= tblsDt Rows[i][ Name ]%> /> </td> <td> <a ?action=show&tblname=<%= tblsDt Rows[i][ Name ]%> > <%= tblsDt Rows[i][ Name ]%> </a>[ <a ?action=insert&tblname=<%= tblsDt Rows[i][ Name ]%> >添加</a> | <a ?action=structure&tblname=<%= tblsDt Rows[i][ Name ]%> > 结构</a> | <a ?action=droptable&tblname=<%= tblsDt Rows[i][ Name ]%> onclick= return confirm( 确定删除表 <%= tblsDt Rows[i][ Name ]%> ? ) > 删除表</a> ] </td> <td> <%= tblsDt Rows[i][ Rows ]%> </td> <td> <%= showSize(float Parse(tblsDt Rows[i][ Data_length ] ToString()))%> </td> <td> <%= tblsDt Rows[i][ Create_time ]%> </td> <td> <%= tblsDt Rows[i][ Update_time ]%> </td> </tr> <% %> <tr class= alt > <td> </td> <td> 合计 <%= tblsCount%> </td> <td> <%= tblRowsCount%> </td> <td> <%= showSize(tblDbSize)%> </td> <td colspan= > </td> </tr> <tr class= alt > <td colspan= > <input name= saveasfile value= type= checkbox id= cbSaveFile runat= server /> 保存为文件 <input class= input name= path type= text size= id= txtSavePath runat= server /> <input class= bt type= submit name= downrar value= 导出所选表 id= btnExport runat= server onserverclick= btnExport_ServerClick /> </td> </tr> </table> </asp:Panel> <asp:Panel ID= PanShow runat= server Visible= false EnableViewState= false > <table border= cellpadding= cellspacing= > <tr class= head > <td> Action</td> <% DataTable dColumn = TableColumn(Request QueryString[ tblname ] ToString() Trim()); for (int i = ; i < dColumn Rows Count; i++) %> <td nowrap> <%= dColumn Rows[i][ ]%> <br> <span> <%= dColumn Rows[i][ ]%> </span> </td> <% %> </tr> <% DataTable dData = RunTable(sql_query Value); string tblPkName = FindPK(Request QueryString[ tblname ] ToString() Trim()); for (int i = ; i < dData Rows Count; i++) %> <tr class= alt<%=i% == ? : %> onmouseover= this className= focus ; onmouseout= this className= alt<%=i% == ? : %> ; > <td nowrap> <%if (tblPkName != string Empty) %> <a ?action=edit&tblname=<%=Request QueryString[ tblname ] %>&pk=<%=tblPkName %>&v=<%=dData Rows[i][tblPkName] %> > 编辑</a> | <a ?action=deldata&tblname=<%=Request QueryString[ tblname ] %>&pk=<%=tblPkName %>&v=<%=dData Rows[i][tblPkName] %> onclick= return confirm( 确定删除该记录? ) >删除</a> <% %> </td> <% for (int j = ; j < dData Columns Count; j++) %> <td nowrap> <%= dData Rows[i][j]%> </td> <% %> </tr> <% %> </table> </asp:Panel> <asp:Panel ID= PanelEdit runat= server Visible= false EnableViewState= false > <h > 在表<%=Request QueryString[ tblname ] Trim() %>中编辑记录 »</h > <table border= cellpadding= cellspacing= > <% DataTable dColumn = TableColumn(Request QueryString[ tblname ] ToString() Trim()); DataTable editData = RunTable( select * from + Request QueryString[ tblname ] ToString() + where + Request QueryString[ pk ] ToString() + = + Request QueryString[ v ] ToString() + ); if (editData Rows Count > ) for (int i = ; i < dColumn Rows Count; i++) %> <tr class= alt<%=i% == ? : %> onmouseover= this className= focus ; onmouseout= this className= alt<%=i% == ? : %> ; > <td> <b> <%= dColumn Rows[i][ ]%> </b> <br /> <%= dColumn Rows[i][ ]%> </td> <td> <textarea class= area name= insertsql_<%= dColumn Rows[i][ ]%> ><%=editData Rows[ ][dColumn Rows[i][ ] ToString() Trim()]%></textarea></td> </tr> <% %> <tr class= alt > <td colspan= > <input class= bt type= submit name= update value= 更新 id= Submit runat= server onserverclick= Submit _ServerClick /> </td> </tr> <% %> </table> </asp:Panel> <asp:Panel ID= PanelInsert runat= server Visible= false EnableViewState= false > <h > 在表<%=Request QueryString[ tblname ] Trim() %>中添加记录 »</h > <table border= cellpadding= cellspacing= > <% DataTable dColumn = TableColumn(Request QueryString[ tblname ] ToString() Trim()); for (int i = ; i < dColumn Rows Count; i++) %> <tr class= alt<%=i% == ? : %> onmouseover= this className= focus ; onmouseout= this className= alt<%=i% == ? : %> ; > <td> <b> <%= dColumn Rows[i][ ]%> </b> <br /> <%= dColumn Rows[i][ ]%> </td> <td> <textarea class= area name= insertsql_<%= dColumn Rows[i][ ]%> ></textarea></td> </tr> <% %> <tr class= alt > <td colspan= > <input class= bt type= submit name= btninsert value= 添加 id= btninsert runat= server onserverclick= btninsert_ServerClick /> </td> </tr> </table> </asp:Panel> <asp:Panel ID= PanelStructure runat= server Visible= false EnableViewState= false > <h > 表<%=Request QueryString[ tblname ] Trim() %>的结构 »</h > <table border= cellpadding= cellspacing= > <tr class= head > <td> Field</td> <td> Type</td> <td> Null</td> <td> Key</td> <td> Default</td> <td> Extra</td> </tr> <% DataTable dColumn = TableStructure(Request QueryString[ tblname ] ToString() Trim()); for (int i = ; i < dColumn Rows Count; i++) %> <tr class= alt<%=i% == ? : %> onmouseover= this className= focus ; onmouseout= this className= alt<%=i% == ? : %> ; > <td> <%= dColumn Rows[i][ ]%> </td> <td> <%= dColumn Rows[i][ ]%> </td> <td> </td> <td> <%= dColumn Rows[i][ ]%> </td> <td> <%= dColumn Rows[i][ ]%> </td> <td> <%= dColumn Rows[i][ ]%> </td> </tr> <% %> </table> </asp:Panel> </asp:Panel> </div> </form> Powered by <a _blank ></a> </body> </> cha138/Article/program/net/201311/13885相关参考
知识大全 ASP.NET项目开发指南:企业信息管理系统数据库连接编写
ASP.NET项目开发指南:企业信息管理系统数据库连接编写 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一
知识大全 ASP.NET项目开发指南:企业信息管理系统数据库概念结构设计
ASP.NET项目开发指南:企业信息管理系统数据库概念结构设计 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来
MySQL与ASP.NET配合更强大 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 开放源代码社
经验之谈:MySQL与ASP.NET配合更强大[2] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
经验之谈:MySQL与ASP.NET配合更强大[1] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
用ODBC连接MySQL和ASP.NET 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 被认为是
知识大全 ASP.NET项目开发指南:企业信息管理系统数据表设计
ASP.NET项目开发指南:企业信息管理系统数据表设计 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧
知识大全 ASP.NET项目开发指南:企业信息管理系统数据表之间的关系
ASP.NET项目开发指南:企业信息管理系统数据表之间的关系 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看
从MySQL导出XLS数据库工具 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!这个脚本是使用Per
介绍: 在我解释cache管理机制时首先让我阐明下一个观念IE下面的数据管理每个人都会用不同的方法去解决如何在IE在管理数据有的会提到用状态管理有的提到的cache管理这里我比较喜欢cache管