By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 2,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Display Access Data

P: n/a
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

Can anyone advise how I go about this?


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

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

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

<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\sk ipassdirect_mainDB.mdb;"
Dim objConnection As New OleDbConnection(strConnection)
Dim strSQL As String = "SELECT countries.countryid, FROM
countries order by country;"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
DGCountries.DataSource = objCommand.ExecuteReader()
End Sub

* 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? an answer to another one
* Search first, post later :
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.