confused noob about ASP, DataSets, and DropDown Lists

S

Stephen D Cook

I am trying to tie a column in a database to a dropdown list, but
having very little luck.
The table is bound to the .aspx page via oledbadapter1 and
oleconnection1, but when I try to create a dataset from it and use one
column of the table, it doesnt work. Either I get an error saying the
type is not a recordset, or it just wont fill the combobox. Please
Help

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim DATechNo As OleDb.OleDbDataAdapter = New
OleDb.OleDbDataAdapter
Dim DSTechNo As Data.DataSet = New Data.DataSet
Dim dc As DataSet = CType(DDTechNo.DataSource, Data.DataSet)
Dim RS As String
RS = "SELECT * FROM TechNumber.TechNumber"
DDTechNo.DataSource(me.OleDbDataAdapter1.Fill(dc,1,,
TechNumber)
DDTechNo.DataBind(TechNumber)




OleDbConnection1.Close()
OleDbConnection1 = Nothing

The name of the Table and column are both TechNumber. In The Line
DDTechNo.DataSource(me oldedbdataadapter1.Fill(dc, 1, , TechNumber)
TechNumber is supposed to be the table I am using, but ASP.NET doesnt
recognize it.

This project is a conversion of an ACCESS 2003 database with forms to
an ASP.NET web based database using VB 2003.

Any help will be much appreciated.
 
B

Barrie Wilson

Stephen D Cook said:
I am trying to tie a column in a database to a dropdown list, but
having very little luck.
The table is bound to the .aspx page via oledbadapter1 and
oleconnection1, but when I try to create a dataset from it and use one
column of the table, it doesnt work. Either I get an error saying the
type is not a recordset, or it just wont fill the combobox. Please
Help

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim DATechNo As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
Dim DSTechNo As Data.DataSet = New Data.DataSet
Dim dc As DataSet = CType(DDTechNo.DataSource, Data.DataSet)
Dim RS As String
RS = "SELECT * FROM TechNumber.TechNumber"
DDTechNo.DataSource(me.OleDbDataAdapter1.Fill(dc,1,,TechNumber)
DDTechNo.DataBind(TechNumber)


that's a little hard to follow, but try this:

OleDbDataAdapter1.Fill(dc)
DDTechNo.DataSource = dc
DDTechNo.DataBind()

in place of the last two statements in your code ... but I don't see a
connection anywhere ... ?? so what is the adapter talking to and how?
where's the data?

if you rearrange your code a bit you can instantiate the DataAdapter as so:
Dim DATechNo As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(RS,
oConnection)

but of course you need oConnection first:

Dim oConnection as OleDbConnection = new
OleDbConnection(<connection_string>) 'YOU supply <connection_string>

:: you ought to work on those naming conventions a bit; this code is not
easy to read, and I'll bet it's not easy for you either
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top