您的位置:首页 > 数据库 > MySQL

使用MySQL的慢查询日志找到低效的SQL语句

2013-01-17 14:17 1011 查看



源代码:
<asp:DataList ID="DataList1" runat="server" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black"
Height="16px" Width="848px">
<AlternatingItemStyle BackColor="PaleGoldenrod" />
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<SelectedItemStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<ItemTemplate>
<img src="image/1.jpg" height="40" width="40">
留言者: <%# Eval("username") %>
EMAIL: <%# Eval("email") %>
留言时间: <%# Eval("posttime")%>         <asp:LinkButton
ID="LinkButton1" runat="server">回复留言</asp:LinkButton>
   
<asp:LinkButton ID="LinkButton2" runat="server">删除留言</asp:LinkButton>
<br/><hr/>
留言内容: <%# Eval("contente")%> <br/><hr/>

回复内容: <%# Eval("reply")%> <br/><hr/>

</ItemTemplate>
</asp:DataList>
查看留言界面:
protected void Page_Load(object sender, EventArgs e)
{
string conn = "Data Source=.;Initial Catalog=Information;Integrated Security=True";
SqlConnection con = new SqlConnection(conn);
string sqlstr = "select*from Message";
SqlDataAdapter ad = new SqlDataAdapter(sqlstr,con);
DataSet ds = new DataSet();
con.Open();
ad.Fill(ds);
con.Close();
DataList1.DataSource = ds.Tables[0].DefaultView;
DataList1.DataBind();
}



留言界面:
using System.Data.SqlClient;
using System.Data;
protected void Button2_Click(object sender, EventArgs e)//取消留言
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)//发送留言
{
string conn = "Data Source=.;Initial Catalog=Information;Integrated Security=True";
SqlConnection con = new SqlConnection(conn);
string sqlstr = "insert into Message(username,sex,email,contente,imageadd)values('" + TextBox1.Text + "','" + RadioButtonList1.SelectedValue + "','" + TextBox2.Text + "','" + TextBox3.Text + "','3.jpg')";
SqlDataAdapter ad = new SqlDataAdapter(sqlstr, con);
DataSet ds = new DataSet();
ad.Fill(ds);
}
本文出自 “软件开发” 博客,请务必保留此出处http://46101994.blog.51cto.com/8842603/1401409
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: