hi
how can i list items from a database(MS Access) in a DropDownList in ASP.NET
This is far too general of a question. Which specific area do you need help understanding? Access queries? Data-binding? The DropDownList server control?
This is far too general of a question. Which specific area do you need help understanding? Access queries? Data-binding? The DropDownList server control?
:o
it is a DropDownList server control ,, and i want to list items in it from a table in a database
is my question understandable enough?:?:
Your question is perfectly understandable, it just is too general.
There are several ways to tackle this. You can simply do a query, return the results as a DataReader, loop through the reader, adding the records to the DropDownList. Or, you can do data binding to one of the data objects.
So, where to start? Do you know how to use .NET's data access objects? Do you know SQL?
I'm not trying to be difficult, but you have to give us somewhere to start. Outline what you already know and have tried. Tell us what specific line of code you'd like to write, but can't.
i wrote these lines
sub page_Load (sender as Object, e as EventArgs)
dim myconnect as OleDbconnection = new OleDbconnection
dim myadapter as oledbadapter= new oledbadapter
dim mycommand as oledbcommand = new oledbcommand
dim myDataSet as DataSet = new OleDbAdapter
myconnect.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=sales.mdb"
myconnect.open()
mycommand.connection = myconnect
myadapter.selectcomand = mycommand
mycommand.commandText="SELECT * FROM Items"
myadapter.fill(MyDataSet, "Items")
DropDownList2.datasource=myDataSat.Tables("Items")
DropDownList2.DataBind
myconnect.colse()
End Sub
thanx for your help
some changes
sub page_Load (sender as Object, e as EventArgs)
dim myconnect as OleDbconnection = new OleDbconnection
dim myadapter as oledbdataadapter= new oledbdataadapter
dim mycommand as oledbcommand = new oledbcommand
dim myDataSet as DataSet = new dataset myconnect.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=sales.mdb" myconnect.open()
mycommand.connection = myconnect
myadapter.selectcommand = mycommand
mycommand.commandText="SELECT * FROM Items"
myadapter.fill(MyDataSet, "Items")
DropDownList2.datasource=myDataSet.Tables("Items")
DropDownList2.DataBind End Sub
another problem ....
Could not find installable ISAM
what is this error means???
Ah, VB.NET. Sorry, I code in C#, so immediately things look sloppy to me: no parantheses after your method calls, no line termination marks... but that might be normal in VB.NET, I don't know.
Perhaps someone who knows/uses VB can step in... but the concept looks fine. What does or doesn't work?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.