Wednesday, March 21, 2012

populated a dropdown with data in the rows, but populating a dropdown with names of the co

within my pageload i have
SqlConnection rate;
SqlCommand Selct;
SqlDataReader dbresults;
rate = new SqlConnection( @dotnet.itags.org."xoxo");
rate.Open();
Selct = new SqlCommand( "Select UserID From dbo.Users", rate );
dbresults = Selct.ExecuteReader();
DropDownList1.DataSource = dbresults;
DropDownList1.DataTextField = "UserID*";
DropDownList1.DataBind();
dbresults.Close();
rate.Close();try out

...
myda = New SqlClient.SqlDataAdapter("Select * from <tablename>" , myconnection)
ds = New DataSet()
myda.Fill(ds, "TableName")
Dim dc As DataColumn
For Each dc In ds.Tables(0).Columns
ddl.Items.Add(dc.ColumnName)
Next
.....

HTH
ok heres another one ive been trying to figure out , how do a populate a drop down list with each table name in a database

0 comments:

Post a Comment