Heim > Datenbank > MySQL-Tutorial > Hauptteil

MySQL数据库和sqlserver压力监测程序实操

WBOY
Freigeben: 2016-06-07 16:11:30
Original
801 Leute haben es durchsucht

你是否对获压力监测程序MySQL数据库和sqlserver的实际操作感到很是头疼?别急,以下的文章将会给你相应的解决方案,以下的文章主要是介绍获得压力监测程序 MySQL数据库和sqlserver的方案,以下就是其具体内容描述。 usingSystem.Data; usingSystem.Data.SqlC

你是否对获压力监测程序MySQL数据库和sqlserver的实际操作感到很是头疼?别急,以下的文章将会给你相应的解决方案,以下的文章主要是介绍获得压力监测程序 MySQL数据库和sqlserver的方案,以下就是其具体内容描述。

<ol class="dp-xml">
<li class="alt"><span><span>using System.Data;  </span></span></li>
<li><span>using System.Data.SqlClient;  </span></li>
<li class="alt"><span>using System.Configuration;  </span></li>
<li><span>using System.Web;  </span></li>
<li class="alt"><span>using System.Web.Security;  </span></li>
<li><span>using System.Web.UI;  </span></li>
<li class="alt"><span>using System.Web.UI.WebControls;  </span></li>
<li><span>using System.Web.UI.WebControls.WebParts;  </span></li>
<li class="alt"><span>using System.Web.UI.HtmlControls;  </span></li>
<li>
<span>using </span>MySQL<span>(和PHP搭配之最佳组合)DriverCS;  </span>
</li>
<li class="alt">
<span>/// </span><span class="tag"><span class="tag-name">summary</span><span class="tag">></span><span> </span></span>
</li>
</ol>
Nach dem Login kopieren

db 的摘要说明

<ol class="dp-xml">
<li class="alt"><span><span>/// </span><span class="tag"></span><span class="tag-name">summary</span><span class="tag">></span><span> </span></span></li>
<li><span>public class db  </span></li>
<li class="alt"><span>{  </span></li>
<li><span>public db()  </span></li>
<li class="alt"><span>{  </span></li>
<li><span>//  </span></li>
<li class="alt"><span>// TODO: 在此处添加构造函数逻辑  </span></li>
<li><span>//  </span></li>
<li class="alt"><span>}  </span></li>
<li><span>/* public static SqlConnection createCon()  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>return new SqlConnection("</span><span class="attribute">server</span><span>=.;</span><span class="attribute">database</span><span>=</span><span class="attribute-value">ylcg</span><span>;</span><span class="attribute">uid</span><span>=</span><span class="attribute-value">sa</span><span>;</span><span class="attribute">pwd</span><span>=</span><span class="attribute-value">123456</span><span>;");  </span>
</li>
<li class="alt"><span>}*/  </span></li>
<li>
<span>public static </span>MySQL<span>(和PHP搭配之最佳组合)Connection createCon()  </span>
</li>
<li class="alt"><span>{  </span></li>
<li>
<span>return new </span>MySQL<span>(和PHP搭配之最佳组合)Connection(new </span>MySQL<span>(和PHP搭配之最佳组合)ConnectionString("localhost","ylcg","root","123456").AsString);  </span>
</li>
<li class="alt"><span>}  </span></li>
<li><span>/* public static DataTable ylTable()  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>SqlConnection </span><span class="attribute">con</span><span> = </span><span class="attribute-value">db</span><span>.createCon();  </span>
</li>
<li class="alt">
<span>SqlDataAdapter </span><span class="attribute">sda</span><span> = </span><span class="attribute-value">new</span><span> SqlDataAdapter();  </span>
</li>
<li>
<span class="attribute">sda.SelectCommand</span><span> = </span><span class="attribute-value">new</span><span> SqlCommand("select * from yl", con);  </span>
</li>
<li class="alt">
<span>DataSet </span><span class="attribute">myds</span><span> = </span><span class="attribute-value">new</span><span> DataSet();  </span>
</li>
<li><span>sda.Fill(myds, "yl");  </span></li>
<li class="alt"><span>sda.Dispose();  </span></li>
<li><span>con.Close();  </span></li>
<li class="alt"><span>return myds.Tables["yl"];   </span></li>
<li><span>}*/  </span></li>
<li class="alt"><span>public static DataTable ylTable()  </span></li>
<li><span>{  </span></li>
<li class="alt">MySQL<span>(和PHP搭配之最佳组合)Connection </span><span class="attribute">con</span><span> = </span><span class="attribute-value">db</span><span>.createCon();  </span>
</li>
<li>MySQL<span>(和PHP搭配之最佳组合)DataAdapter </span><span class="attribute">sda</span><span> = </span><span class="attribute-value">new</span><span> </span>MySQL<span>(和PHP搭配之最佳组合)DataAdapter();  </span>
</li>
<li class="alt">
<span class="attribute">sda.SelectCommand</span><span> = </span><span class="attribute-value">new</span><span> </span>MySQL<span>(和PHP搭配之最佳组合)Command("select * from yl",con);  </span>
</li>
<li>
<span>DataSet </span><span class="attribute">myds</span><span> = </span><span class="attribute-value">new</span><span> DataSet();  </span>
</li>
<li class="alt"><span>sda.Fill(myds, "yl");  </span></li>
<li><span>sda.Dispose();  </span></li>
<li class="alt"><span>con.Close();  </span></li>
<li><span>return myds.Tables["yl"];   </span></li>
<li class="alt"><span>}  </span></li>
<li><span>/* public static void insertNew(int num)  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>SqlConnection </span><span class="attribute">con</span><span> = </span><span class="attribute-value">db</span><span>.createCon();  </span>
</li>
<li class="alt">
<span>SqlCommand </span><span class="attribute">cmd</span><span> = </span><span class="attribute-value">new</span><span> SqlCommand();  </span>
</li>
<li><span>try  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>for (int </span><span class="attribute">i</span><span> = </span><span class="attribute-value">0</span><span>; i </span><span class="tag"><span> </span><span class="tag-name">100</span><span>; i++)  </span></span>
</li>
<li class="alt"><span>{  </span></li>
<li>
<span>string[] </span><span class="attribute">times</span><span> ={"00:10","00:20","00:30","00:40","00:50",  </span>
</li>
<li class="alt"><span>"01:10","01:20","01:30","01:40","01:50",  </span></li>
<li><span>"02:10","02:20","02:30","02:40","02:50",  </span></li>
<li class="alt"><span>"03:10","03:20","03:30","03:40","03:50",  </span></li>
<li><span>"04:10","04:20","04:30","04:40","04:50",  </span></li>
<li class="alt"><span>"05:10","05:20","05:30","05:40","05:50",  </span></li>
<li><span>"06:10","06:20","06:30","06:40","06:50",  </span></li>
<li class="alt"><span>"07:10","07:20","07:30","07:40","07:50",  </span></li>
<li><span>"08:10","08:20","08:30","08:40","09:50",  </span></li>
<li class="alt"><span>"10:10","10:20","10:30","10:40","10:50",  </span></li>
<li><span>"11:10","11:20","11:30","11:40","11:50",  </span></li>
<li class="alt"><span>"12:10","12:20","12:30","12:40","12:50",  </span></li>
<li><span>"13:10","13:20","13:30","13:40","13:50",  </span></li>
<li class="alt"><span>"14:10","14:20","14:30","14:40","14:50",  </span></li>
<li><span>"15:10","15:20","15:30","15:40","15:50",  </span></li>
<li class="alt"><span>"16:10","16:20","16:30","16:40","16:50",  </span></li>
<li><span>"17:10","17:20","17:30","17:40","17:50",  </span></li>
<li class="alt"><span>"18:10","18:20","18:30","18:40","18:50",  </span></li>
<li><span>"19:10","19:20","19:30","19:40","19:50"};  </span></li>
<li class="alt">
<span>System.Random </span><span class="attribute">r</span><span> = </span><span class="attribute-value">new</span><span> Random();  </span>
</li>
<li>
<span>int </span><span class="attribute">myyl</span><span> = </span><span class="attribute-value">r</span><span>.Next(1120, 1890);  </span>
</li>
<li class="alt">
<span>string </span><span class="attribute">sql</span><span> = </span><span class="attribute-value">"insert into yl values('"</span><span> + times[i].ToString() + "'," + myyl + ",11)";  </span>
</li>
<li><span>// System.Web.HttpContext.Current.Response.Write(sql);  </span></li>
<li class="alt"><span>con.Open();  </span></li>
<li>
<span class="attribute">cmd.Connection</span><span> = </span><span class="attribute-value">con</span><span>;  </span>
</li>
<li class="alt">
<span class="attribute">cmd.CommandType</span><span> = CommandType.Text;  </span>
</li>
<li>
<span class="attribute">cmd.CommandText</span><span> = </span><span class="attribute-value">sql</span><span>;  </span>
</li>
<li class="alt"><span>cmd.ExecuteNonQuery();  </span></li>
<li><span>cmd.Dispose();  </span></li>
<li class="alt"><span>con.Close();  </span></li>
<li><span>}  </span></li>
<li class="alt"><span>}  </span></li>
<li><span>catch  </span></li>
<li class="alt"><span>{  </span></li>
<li><span>System.Web.HttpContext.Current.Response.Write("dd");  </span></li>
<li class="alt"><span>}   </span></li>
<li><span> </span></li>
<li class="alt"><span>}*/  </span></li>
<li><span>public static void insertNew(int num)  </span></li>
<li class="alt"><span>{  </span></li>
<li>MySQL<span>(和PHP搭配之最佳组合)Connection </span><span class="attribute">con</span><span> = </span><span class="attribute-value">db</span><span>.createCon();  </span>
</li>
<li class="alt">MySQL<span>(和PHP搭配之最佳组合)Command </span><span class="attribute">cmd</span><span> = </span><span class="attribute-value">new</span><span> </span>MySQL<span>(和PHP搭配之最佳组合)Command();  </span>
</li>
<li><span>try  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>for (int </span><span class="attribute">i</span><span> = </span><span class="attribute-value">0</span><span>; i </span><span class="tag"><span> </span><span class="tag-name">100</span><span>; i++)  </span></span>
</li>
<li class="alt"><span>{  </span></li>
<li>
<span>string[] </span><span class="attribute">times</span><span> ={"00:10","00:20","00:30","00:40","00:50",  </span>
</li>
<li class="alt"><span>"01:10","01:20","01:30","01:40","01:50",  </span></li>
<li><span>"02:10","02:20","02:30","02:40","02:50",  </span></li>
<li class="alt"><span>"03:10","03:20","03:30","03:40","03:50",  </span></li>
<li><span>"04:10","04:20","04:30","04:40","04:50",  </span></li>
<li class="alt"><span>"05:10","05:20","05:30","05:40","05:50",  </span></li>
<li><span>"06:10","06:20","06:30","06:40","06:50",  </span></li>
<li class="alt"><span>"07:10","07:20","07:30","07:40","07:50",  </span></li>
<li><span>"08:10","08:20","08:30","08:40","09:50",  </span></li>
<li class="alt"><span>"10:10","10:20","10:30","10:40","10:50",  </span></li>
<li><span>"11:10","11:20","11:30","11:40","11:50",  </span></li>
<li class="alt"><span>"12:10","12:20","12:30","12:40","12:50",  </span></li>
<li><span>"13:10","13:20","13:30","13:40","13:50",  </span></li>
<li class="alt"><span>"14:10","14:20","14:30","14:40","14:50",  </span></li>
<li><span>"15:10","15:20","15:30","15:40","15:50",  </span></li>
<li class="alt"><span>"16:10","16:20","16:30","16:40","16:50",  </span></li>
<li><span>"17:10","17:20","17:30","17:40","17:50",  </span></li>
<li class="alt"><span>"18:10","18:20","18:30","18:40","18:50",  </span></li>
<li><span>"19:10","19:20","19:30","19:40","19:50"};  </span></li>
<li class="alt">
<span>System.Random </span><span class="attribute">r</span><span> = </span><span class="attribute-value">new</span><span> Random();  </span>
</li>
<li>
<span>int </span><span class="attribute">myyl</span><span> = </span><span class="attribute-value">r</span><span>.Next(1120, 1890);  </span>
</li>
<li class="alt">
<span>string </span><span class="attribute">sql</span><span> = </span><span class="attribute-value">"insert into yl(sendtime,sendvalue,cgID) values('"</span><span> + times[i].ToString() + "'," + myyl + ",11)";  </span>
</li>
<li><span>// System.Web.HttpContext.Current.Response.Write(sql);  </span></li>
<li class="alt"><span>con.Open();  </span></li>
<li>
<span class="attribute">cmd.Connection</span><span> = </span><span class="attribute-value">con</span><span>;  </span>
</li>
<li class="alt">
<span class="attribute">cmd.CommandType</span><span> = CommandType.Text;  </span>
</li>
<li>
<span class="attribute">cmd.CommandText</span><span> = </span><span class="attribute-value">sql</span><span>;  </span>
</li>
<li class="alt"><span>cmd.ExecuteNonQuery();  </span></li>
<li><span>cmd.Dispose();  </span></li>
<li class="alt"><span>con.Close();  </span></li>
<li><span>}  </span></li>
<li class="alt"><span>}  </span></li>
<li><span>catch  </span></li>
<li class="alt"><span>{  </span></li>
<li><span>System.Web.HttpContext.Current.Response.Write("dd");  </span></li>
<li class="alt"><span>}  </span></li>
<li><span>}   </span></li>
<li class="alt"><span>}  </span></li>
<li>MySQL<span>(和PHP搭配之最佳组合)</span><span class="tag">></span><span> create table yl( ylID int(10) unsigned NOT NULL AUTO_INCREMENT Prima(最完善的虚拟主机管理系统)ry ke  </span>
</li>
<li class="alt">
<span>y, sendtime varchar(20), sendvalue int(10), cgID int(10) not null) </span><span class="attribute">ENGINE</span><span>=</span><span class="attribute-value">MyISAM</span><span> </span>
</li>
<li>
<span class="attribute">AUTO_INCREMENT</span><span>=</span><span class="attribute-value">1</span><span> DEFAULT </span><span class="attribute">CHARSET</span><span>=</span><span class="attribute-value">utf8</span><span>;  </span>
</li>
</ol>
Nach dem Login kopieren

以上的相关内容就是对压力监测程序sqlserver和MySQL数据库的介绍,望你能有所收获。


Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage