how to get values from the database to a dropdown list [modified]
-
please send me the code to get values from the database(SQL Server 2000) to a dropdown list in ASP.Net. -- modified at 3:14 Friday 24th August, 2007
Which database? Which language? Use an OleDbConnection and a command object to perform a sql query and then as you loop through your results populate the list. You can find documentation on this in the MSDN.
-
please send me the code to get values from the database(SQL Server 2000) to a dropdown list in ASP.Net. -- modified at 3:14 Friday 24th August, 2007
try the following code: C#: ----- SqlConnection con = new SqlConnection(connectionString); String sql = "SELECT FROM "; SqlCommand cmd =new SqlCommand(sql,con); SqlDataAdapter sda =new SqlDataAdapter(cmd); DataTable dt =new DataTable(); con.Open(); sda.Fill(dt); DropDownList1.DataSource =dt; DropDownList1.DataBind();
-
please send me the code to get values from the database(SQL Server 2000) to a dropdown list in ASP.Net. -- modified at 3:14 Friday 24th August, 2007
SqlConnection con= new SqlConnection("Server=IBM;DataSource=Master;User Id=sa;Pwd=sa"); SqlDataAdapter ada=new SqlDataAdapter("select * from customer",con); DataSet ds=new DataSet(); ada.Fill(ds); DropDownList1.DataSource=ds1.Tables[0]; DropDownList1.DataTextField=ds1.Tables[0].Columns[1].ToString(); DropDownList1.DataValueField=ds1.Tables[0].Columns[1].ToString(); DropDownList1.DataBind();
VanithaVasu
-
please send me the code to get values from the database(SQL Server 2000) to a dropdown list in ASP.Net. -- modified at 3:14 Friday 24th August, 2007
First create Connection with database and then Dim databaseRecord As SqlDataAdapter Dim dstRecord As DataSet databaseRecord = New SqlDataAdapter("Select * from ", con) dstRecords = New DataSet databaseRecord .Fill(dstRecords) dropdownlistname.DataSource = dstRecords dropdownlistname.DataTextField = "" dropdownlistname.DataValueField = "" dropdownlistname.DataBind()
ash83
-
please send me the code to get values from the database(SQL Server 2000) to a dropdown list in ASP.Net. -- modified at 3:14 Friday 24th August, 2007
First create Connection with database and then Dim databaseRecord As SqlDataAdapter Dim dstRecord As DataSet databaseRecord = New SqlDataAdapter("Select * from ", con) dstRecords = New DataSet databaseRecord .Fill(dstRecords) dropdownlistname.DataSource = dstRecords dropdownlistname.DataTextField = "" dropdownlistname.DataValueField = "" dropdownlistname.DataBind() I hope this will workout
ash83