Help with Data in VS2008 Web Developer

T

Ty

I'm using Web Developer in VS 2008.

I have a MS Access DB that I want access the data to place into labels
and fill dropdown list boxes.

The problem is that I am use to VB 6 and ADO where I could just code
it without much fuss.

Now the issues I have are....

1. Where do I place the code? In the aspx page as VBscript or in the
apsx.vb page as code?

I looked on the web and I find that the recordset object has been
replaced with the dataset. There is also a dataadapter needed to fill
the dataset. None of it makes much sense to me. I added a dataset to
my site by add new item...dataset and used the wizard to connect to
the database and the query builder to fill data from the table but how
do i use this in the aspx pages? and Do I have to add a new one for
each table I need to access for different pages?



Most of the examples I have seen use a SQL database and I cannot see
how to change it to my use.

Any help or a simple example of creating a connection, command and
getting the data into variables would be greatly appreciated.



I have been able to use a gridview with accessdatasource without issue
but the data I need to input now is into controls that do not have a
data bound property such as a label and textbox.



Thanks,

Ty
 
A

aaron.kempf

MDB is obsolete.

Seriously WTF Is wrong with your decision-making abilities?

If you want to change a SQL Server database; you should probably find
'SQL Server Management Studio Express'.

THanks

-Aaron
 
R

rowe_newsgroups

I'm using Web Developer in VS 2008.

I have a MS Access DB that I want access the data to place into labels
and fill dropdown list boxes.

The problem is that I am use to VB 6 and ADO where I could just code
it without much fuss.

Now the issues I have are....

1. Where do I place the code? In the aspx page as VBscript or in the
apsx.vb page as code?

I looked on the web and I find that the recordset object has been
replaced with the dataset. There is also a dataadapter needed to fill
the dataset. None of it makes much sense to me. I added a dataset to
my site by add new item...dataset and used the wizard to connect to
the database and the query builder to fill data from the table but how
do i use this in the aspx pages? and Do I have to add a new one for
each table I need to access for different pages?

Most of the examples I have seen use a SQL database and I cannot see
how to change it to my use.

Any help or a simple example of creating a connection, command and
getting the data into variables would be greatly appreciated.

I have been able to use a gridview with accessdatasource without issue
but the data I need to input now is into controls that do not have a
data bound property such as a label and textbox.

Thanks,

Ty

First, go here and get your connection string for Access:

www.connectionstrings.com

Then, you can try this code (typed in message so watch out for errors)
and loop through the data returned from a query.

/////////////
'// Add to the top of the code file:
'// Imports System.Data.OleDb

Using conn As New OleDbConnection("your connection string from
www.connectionstrings.com")
Using com As OleDbCommand = conn.CreateCommand()
conn.Open() '// If you fail here your conn string is probably
wrong

com.CommandType = CommandType.Text
com.CommandText = "SELECT Name FROM tbl_Names"

Using dr As OleDbDataReader = com.ExecuteReader()
While dr.Read()
Dim name As String = dr("Name").ToString()

Me.listBox1.Items.Add(name)
End While
End Using
End Using
End Using
///////////////

Let me know how well it goes, I typed that really quick.

Thanks,

Seth Rowe [MVP]
 
T

Ty

MDB is obsolete.

Seriously WTF Is wrong with your decision-making abilities?

If you want to change a SQL Server database; you should probably find
'SQL Server Management Studio Express'.

THanks

-Aaron

There really is no reason to be rude!

I'm using Access for testing and learning because thats what the DB
was written in. I will later have to convert it to SQL Server but at
this time it is not my decision to make.

You comments are neither helpful or necessary. Unless you have
something helpful to the questions I asked please refrain from posting
your dribble.

Ty
 
T

Ty

First, go here and get your connection string for Access:

www.connectionstrings.com

Then, you can try this code (typed in message so watch out for errors)
and loop through the data returned from a query.

/////////////
'// Add to the top of the code file:
'// Imports System.Data.OleDb

Using conn As New OleDbConnection("your connection string fromwww.connectionstrings.com")
    Using com As OleDbCommand = conn.CreateCommand()
        conn.Open() '// If you fail here your conn string is probably
wrong

        com.CommandType = CommandType.Text
        com.CommandText = "SELECT Name FROM tbl_Names"

        Using dr As OleDbDataReader = com.ExecuteReader()
            While dr.Read()
                Dim name As String = dr("Name").ToString()

                Me.listBox1.Items.Add(name)
            End While
        End Using
    End Using
End Using
///////////////

Let me know how well it goes, I typed that really quick.

Thanks,

Seth Rowe [MVP]- Hide quoted text -

- Show quoted text -

Thanks Seth thats exactly what I needed to get started and build upon.

Ty
 
A

aaron.kempf

Access isn't easier for testing with!!!

Do you rewrite your underwear twice a day?

I don't mean to be rude-- I just think that there is a better way than
always rewriting Access databases.. because they're not reliable--
they don't scale. and they're just 'not good enough' for real world
usage.

-Aaron
 

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

Top