<Html>
<head>
<TITLE>分析數據庫結構,自動生成代碼</TITLE>
<meta http-equiv="Content-Type" content="text/Html; charset=gb2312">
</head>
<frameset cols="237,767" rows="*">
<frame src="dbXML.ASPx">
<frame name="code" src="about:blank">
</frameset>
</Html>
########################### dbXML.ASPx 文件內容,該文件沒有C#代碼文件 #############
<script language="C#" runat ="server">
System.Xml.XmlDocument myCfgXML = new System.Xml.XMLDocument();
// 獲得系統配置字符串
string GetAppConfig(string strKey)
{
System.Xml.XmlElement cfgElement = myCfgXML.SelectSingleNode ("//setting[@key=''" + strKey + "'']" )
as System.Xml.XMLElement ;
if( cfgElement == null )
return "";
else
return cfgElement.InnerText ;
}
// 判斷字符串是否是空白字符串
bool isBlankString(string strText )
{
if(strText != null)
{
int iCount;
for(iCount=0;iCount<strText.Length ;iCount++)
{
if(System.Char.IsWhiteSpace ( strText[iCount])==false)
return false;
}
}
return true;
}
void Page_Load(Object sender, EventArgs e)
{
// 加載系統配置文件
myCfgXML.Load(this.MapPath(".") + "\\dbxmlcfg.XML");
string strType = this.Request["type"];
string strXSL = "main.XML";
if(strType == null)
strType = "querytable";
System.Xml.XmlDocument myDoc = new System.Xml.XMLDocument();
myDoc.LoadXml("<dbXML />");
string strConnection = GetAppConfig("conndbXML");
System.Text.Encoding myEncode = System.Text.Encoding.GetEncoding(936);
if(isBlankString(strConnection)==false)
{
using(System.Data.OleDb.OleDbConnection myConn = new System.Data.OleDb.OleDbConnection(strConnection))
{
myConn.Open();
if(myConn.State == System.Data.ConnectionState.Open )
{
string strSQL = GetAppConfig(strType + "_" + myConn.Provide