473,394 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Access Connection

Hi All,

I have pieced together this from a couple of samples:

<%@ Control Language="vb" %>
<Script runat="Server">
Public Function GetConnection()
Import System.Data.OleDb
Dim Conn as OleDbConnection
Dim ConnStr as String
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\Simon\My
Documents\Adotek\Projects\SkiPassDirect\private\sk ipassdirect_mainDB.mdb"
'For password protected DB's add "Userid=xxxx;Password=xxxxx" to the above
string
Conn=new OleDbConnection(ConnStr)
end Function
</Script>

This is in "database_connection.ascx"

I am registering the class like this:
<%@ Register TagPrefix="SPD" TagName="DBConnection"
src="/assets/classes/database_connection.ascx"%>

And opening the connection like this:
<SPD:DBConnection id="DBConnection" runat="Server"/>

I get the following error:
Compiler Error Message: BC30451: Name 'Import' is not declared.
Source Error:
Line 2: <Script runat="Server">
Line 3: Public Function GetConnection()
Line 4: Import System.Data.OleDb
Line 5: Dim Conn as OleDbConnection
Line 6: Dim ConnStr as String

Can anyone advise where I've gone wrong?

Thanks!!

Simon.
--
-
* 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
2 1120
The Import System.Data.OleDb is in the wrong place. It must always be
outside the actual class or functions. You've got it as part of a function.
Instead, move it to it's own statement one line below the Control derective.

Hope this helsp,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Simon Harris" <to*********@makesyoufat.com> wrote in message
news:eN**************@tk2msftngp13.phx.gbl...
Hi All,

I have pieced together this from a couple of samples:

<%@ Control Language="vb" %>
<Script runat="Server">
Public Function GetConnection()
Import System.Data.OleDb
Dim Conn as OleDbConnection
Dim ConnStr as String
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\Simon\My
Documents\Adotek\Projects\SkiPassDirect\private\sk ipassdirect_mainDB.mdb"
'For password protected DB's add "Userid=xxxx;Password=xxxxx" to the above string
Conn=new OleDbConnection(ConnStr)
end Function
</Script>

This is in "database_connection.ascx"

I am registering the class like this:
<%@ Register TagPrefix="SPD" TagName="DBConnection"
src="/assets/classes/database_connection.ascx"%>

And opening the connection like this:
<SPD:DBConnection id="DBConnection" runat="Server"/>

I get the following error:
Compiler Error Message: BC30451: Name 'Import' is not declared.
Source Error:
Line 2: <Script runat="Server">
Line 3: Public Function GetConnection()
Line 4: Import System.Data.OleDb
Line 5: Dim Conn as OleDbConnection
Line 6: Dim ConnStr as String

Can anyone advise where I've gone wrong?

Thanks!!

Simon.
--
-
* 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 #2

"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
The Import System.Data.OleDb is in the wrong place. It must always be
outside the actual class or functions. You've got it as part of a function. Instead, move it to it's own statement one line below the Control derective.
Hope this helsp,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Simon Harris" <to*********@makesyoufat.com> wrote in message
news:eN**************@tk2msftngp13.phx.gbl...
Hi All,

I have pieced together this from a couple of samples:

<%@ Control Language="vb" %>
<Script runat="Server">
Public Function GetConnection()
Import System.Data.OleDb
Dim Conn as OleDbConnection
Dim ConnStr as String
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\Simon\My
Documents\Adotek\Projects\SkiPassDirect\private\sk ipassdirect_mainDB.mdb" 'For password protected DB's add "Userid=xxxx;Password=xxxxx" to the

above
string
Conn=new OleDbConnection(ConnStr)
end Function
</Script>

This is in "database_connection.ascx"

I am registering the class like this:
<%@ Register TagPrefix="SPD" TagName="DBConnection"
src="/assets/classes/database_connection.ascx"%>

And opening the connection like this:
<SPD:DBConnection id="DBConnection" runat="Server"/>

I get the following error:
Compiler Error Message: BC30451: Name 'Import' is not declared.
Source Error:
Line 2: <Script runat="Server">
Line 3: Public Function GetConnection()
Line 4: Import System.Data.OleDb
Line 5: Dim Conn as OleDbConnection
Line 6: Dim ConnStr as String

Can anyone advise where I've gone wrong?

Thanks!!

Simon.
--
-
* 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!



Thanks Mark! Works a treat now.

Perhaps you could answer a further question, now I have my database
connection open, do I need to explicitly close it? If so, could you advise
how?

Thanks.
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Peter Larsson | last post by:
Hello everybody, I'm developing a system for a company that has production at two different locations. The production is stored in an Access database at each location, and I need to find a way...
1
by: James | last post by:
Hi, I am trying to access the MS Access database on my local machine in C# Windows Application in Visual Studio.NET. But it seems that it does not work. I use the Microsoft Application Blocks to...
8
by: Evan | last post by:
If there are any enlightend souls out there that can help me, I would greatly appreciate it. I would like to use a macro to take a value and add it to an access database. I am having a problem...
16
by: Rob Geraghty | last post by:
I've just spent some time looking through FAQ sites and searching the google archives of this newsgroup, but I still haven't been able to find a clear explanation of an issue with multi-user...
13
by: Zlatko Matić | last post by:
Is it possible to use Access as front-end for POstgreSQL and how ? What about Access Projects (.adp) and PostgreSQL ?
6
by: jonefer | last post by:
I have two versions of a 'Downtime Application that will run in the event that the mainframe goes down 1) SQL Server ASP.NET app (accessed outside the mainframe network) 2) MS Access Version of...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
0
by: JP | last post by:
Hello: I am using VB 6.0 with a Windows XP Professional environment. I am also using Access 2000. I am currently building a program and need reporting capabilities. So, I started a Data...
8
by: mark_aok | last post by:
Hi all, I have a split database. Both the forms, and the tables are stored on a shared network drive (this is Access 2003). The users use the forms, and the tables on the network drive, there...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.