Display Access Data

S

Simon Harris

Hi All,

I have the following page working Ok, I would like to change it so the
connection is in a 'class library' as Avnraro suggested in a previous post.

Objective is to have a connection object I can use across all my
developments.

Can anyone advise how I go about this?

Thanks!

Simon.


<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.OleDb" %>

<html>
<head>
<title>Connecting To an Access Database</title>
</head>

<body>
<H2>Connecting To an Acess database</H2>
<asp:dataGrid id="DGCountries" runat="server" />
</body>
</html>

<script language="vb" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
Dim strConnection As String = "Provider=Microsoft.Jet.oleDb.4.0;data
source=C:\Documents and Settings\Simon\My
Documents\Adotek\Projects\SkiPassDirect\private\skipassdirect_mainDB.mdb;"
Dim objConnection As New OleDbConnection(strConnection)
Dim strSQL As String = "SELECT countries.countryid, countries.country FROM
countries order by country;"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
objConnection.Open()
DGCountries.DataSource = objCommand.ExecuteReader()
DGCountries.DataBind()
objConnection.Close()
End Sub
</script>

--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top