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
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\sk ipassdirect_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!
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.