< %@Page Language="C#"%> < %@Import Namespace="System"%> < %@Import Namespace="System.Data"%> < %@Import Namespace="System.Data.OleDb"%> < %@Import Namespace="System.Data.SqlClient"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat="server"> void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("server=192.168.123.67;database=OK;uid=sa;pwd=Aj3tk9"); conn.Open(); SqlCommand s_com = new SqlCommand(); s_com.CommandText = "select * from LOTTERY"; //語法如 select * from table_xxx s_com.Connection = conn;
SqlDataReader s_read = s_com.ExecuteReader(); while (s_read.Read()) // 迴圈會執行到沒有下一筆資料為止 { TextBox1.Text += s_read["type"].ToString();
} } </script>
<html xmlns=" http://www.w3.org/1999/xhtml "> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <% SqlConnection conn = new SqlConnection("server=192.168.123.67;database=OK;uid=sa;pwd=Aj3tk9"); conn.Open(); SqlCommand s_com = new SqlCommand(); s_com.CommandText = "select * from LOTTERY"; //語法如 select * from table_xxx s_com.Connection = conn;
SqlDataReader s_read = s_com.ExecuteReader(); while (s_read.Read()) // 迴圈會執行到沒有下一筆資料為止 {
Label2.Text = s_read["L_ID"].ToString(); %> <asp:Label ID="Label2" runat="server" dir="rtl"></asp:Label> <br> <% } %> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> <asp:TextBox ID="TextBox1" runat="server" dir="rtl"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server" dir="rtl"></asp:TextBox> </form> </body> </html>