Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Aspx version of mssql out-of-library script

2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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 = "server=" + serverIP+ "; database=" + database+ "; uid=" + user+ "; pwd=" + pass;System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection (connectionString) Try {connection.Open (); string sqlStr = "select * from" + tableName; if (colNameplate = "") {sqlStr = "select" + colName + "from" + 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 = "No data to export!" ; lblInfo.ForeColor = System.Drawing.Color.Blue;return;} string filePath = System.IO.Path.GetDirectoryName (Server.MapPath ("DataOutExl.aspx")) + "\ DataOut"; if (! System.IO.Directory.Exists (filePath)) {System.IO.Directory.CreateDirectory (filePath);} bool outType = RadioButton1.Checked;int sum = dataTable.Rows.Count;int count = 1; if (txtNum. text = ") {size = int.Parse (txtNum.Text); count = sum / size+1 } for (int z = 0; z < count; zonal +) {Button1.Text = "exporting.."; Button1.Enabled = false;lblInfo.Text = "exporting group data" + (zambi1) + "group data" for a total of "+ count+" group data; lblInfo.ForeColor = System.Drawing.Color.Blue; System.IO.StreamWriter file = new System.IO.StreamWriter (filePath+ "\" + (Zion1) + "_" + fileName, false, Encoding.UTF8); bool isFirst = true If (outType) {file.Write (@ "* {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;} Export Table"); file.Write ("

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report