public partial class WebForm1 : System.Web.UI.Page
{
static string strconn = "Data Source=localhost;database=BOOKS;integrated security=SSPI";
static SqlConnection conn = new SqlConnection(strconn);
static SqlCommand sqlcmd;
static SqlDataReader SqlReader;
protected void Page_Load(object sender, EventArgs e)
{
sqlcmd = conn.CreateCommand();
conn.Open();
sqlcmd.CommandText = "SELECT * FROM ip";
SqlDataAdapter ad = new SqlDataAdapter(sqlcmd);
DataSet set = new DataSet();
ad.Fill(set, "ip");
DataTable tb = set.Tables["ip"];
ListBox1.DataSource = sqlcmd.ExecuteReader();
ListBox1 .DataTextField = "ip";
ListBox1.DataValueField= "id";
ListBox1.DataBind();
conn.Close();
}
}
{
static string strconn = "Data Source=localhost;database=BOOKS;integrated security=SSPI";
static SqlConnection conn = new SqlConnection(strconn);
static SqlCommand sqlcmd;
static SqlDataReader SqlReader;
protected void Page_Load(object sender, EventArgs e)
{
sqlcmd = conn.CreateCommand();
conn.Open();
sqlcmd.CommandText = "SELECT * FROM ip";
SqlDataAdapter ad = new SqlDataAdapter(sqlcmd);
DataSet set = new DataSet();
ad.Fill(set, "ip");
DataTable tb = set.Tables["ip"];
ListBox1.DataSource = sqlcmd.ExecuteReader();
ListBox1 .DataTextField = "ip";
ListBox1.DataValueField= "id";
ListBox1.DataBind();
conn.Close();
}
}