1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| <code>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;
namespace test1
{
public partial class Default : System.Web.UI.Page
{
public void clickMeButton_Click (object sender, EventArgs e)
{
object val = ViewState["ButtonClickCount"];
int i = (val == null)? 1 : (int)val + 1;
outputlabel.Text = string.Format ("You clicked me {0} {1}", i, i==1?"time":"times");
ViewState["ButtonClickCount"] = i;
string query = "select * from reference limit 10";
MySqlConnection myConnection = new MySqlConnection("server=localhost;user id=root;password=root;database=reference_db");
MySqlCommand myCommand=new MySqlCommand(query,myConnection);
myConnection.Open();
myCommand.ExecuteNonQuery();
MySqlDataReader myDataReader = myCommand.ExecuteReader();
string bookres="";
bookres += "<table style=\"width:100%\">";
while (myDataReader.Read()==true)
{
bookres += "<tr><td>";
bookres+=myDataReader["id"];
bookres += "</td><td>";
bookres+=myDataReader["ReferenceType"];
bookres += "</td><td>";
bookres+=myDataReader["Record_Number"];
bookres += "</td></tr>";
}
bookres += "</table>";
myDataReader.Close();
myConnection.Close();
outputlabel.Text = bookres;
}
}
}
|