473,699 Members | 2,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class to handle DB connections

Hi All,

I'm trying to create a class to connect/disconnect a database. Code I have
so far is below, problem is that the closeconn function gives me an error -
Name 'SPDOleDbConnec tion' is not declared.

Also getting the same problem in my code where I want to use the connection
(also shown below)

Would appreciate it if anyone has any ideas - Surely I dont have to repeat
this code everytime I open/close a connection! :)

Regards,
Simon.
Code to open/close connection
=============== =========
Public Class DataBase

Public Function OpenConn() As System.Data.Ole Db.OleDbConnect ion
Dim configurationAp pSettings As
System.Configur ation.AppSettin gsReader = New
System.Configur ation.AppSettin gsReader
Dim SPDOleDbConnect ion As New OleDb.OleDbConn ection
SPDOleDbConnect ion.ConnectionS tring =
CType(configura tionAppSettings .GetValue("OleD bConnection1.Co nnectionString" ,
GetType(System. String)), String)
SPDOleDbConnect ion.Open()
End Function
Public Function CloseConn() As System.Data.Ole Db.OleDbConnect ion
SPDOleDbConnect ion.Close()
End Function

End Class

Code where I want to use the connection
=============== =============== =
Dim myCommand As New System.Data.Ole Db.OleDbCommand ("SELECT Country FROM
Countries WHERE CountryID = " & CountryID, SPDOleDbConnect ion)
Dim myReader As System.Data.Ole Db.OleDbDataRea der =
myCommand.Execu teReader(Comman dBehavior.Close Connection)
While myReader.Read()
Return myReader.GetStr ing(0)
End While
myReader.Close( )
Nov 18 '05 #1
0 838

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

Similar topics

5
3020
by: news | last post by:
Well, I wrote my first PHP class today. Yeah! But to get it to work, in each function within the class I have to repeat the database connection lines, and that just seems redundant; there has to be a better way that I'm just not bright enough to think of. Any suggestions? (It's the first 3 lines of each of the two functions below. When I have it fully written, there will be about 10 similar functions, each repeating those three lines.)
3
1737
by: Brad Navarro | last post by:
OK, I may be asking for the impossible, but I'll give it a shot: For a case like this: using System.Data.SqlClient; abstract class Base { private SqlConnection DBConnect; Base(string SqlConnectStr) { DBConnect = new SqlConnection(SqlConnectStr);
4
386
by: Gav | last post by:
Hi all, This may not be the best way to do things I'm not sure... however I have created a class that handles all the database calls, I didn't want to keep having to create connections to the database or instances of the same class so I wanted to make an instance of the class in the top level window form and be able to access it from the child windows. Is this possible to do? if so how do you access the instance of the class at the top...
1
3332
by: quest | last post by:
My webserver application (a http handler) accepts a sequence of requests from client. Each request requires an access to database (password/username supplied in the request). I am looking at improving the performance of the webserver. My questions: 1. How should I handle the session as the client will post one request after antoher (for may be consequtively 5 requests) ? 2. Is there any way to 'cache' the database connection and reuse...
1
4595
by: Bruce W.1 | last post by:
I want to put a live connection in a web page to periodically updated data. When the data changes, the server notifys the client and gives the new data. The client does not regularly refresh the page. The client responds to server-side events only. The screen display changes without any user interaction. An application like this might be a chat, stock ticker, or data inventory. Sofar as I can tell nothing in the .NET framework can...
5
1990
by: Dave Johnson | last post by:
Working on Asp.net with access database backend,a serious Question in the Class design phase, for accessing the database; Which is Better to make a Connection Class that handles all the ADO Connections for all the other Objects, OR Just make a Connection Module to handle the Database Access,
0
3024
by: Tom P | last post by:
I'm using System.Configuration in .NET 2.0 to load in values from an externally specified config file and deserialize them into a C# class. During deserialization, I'm getting an exception thrown by .NET It's having a problem with the <connections> element seen below. I've tried different things, but still I can't get the deserialize to succeed. Here's the problem in detail below. Can anybody tell me what I'm doing wrong? Shouldn't...
19
1710
by: rich | last post by:
I am building an app using php and postgresql. My questionis this. How do you handle people wanting to make parallel changes to a record. Since in web apps you are doing a select, bring over a record then updating it, there is no lock on that record while you are making the changes in your browser window. Does transactions handle that? Do you make your selection and update all part of the same transaction? This whole scenario has me...
2
2004
by: Daniel Lipovetsky | last post by:
I would like for an object to "report" to a container object when a new instance is created or deleted. I could have a container object that is called when a new instance is created, as below. class AnyObject: pass class Container: links = def add(self,other):
2
18354
by: kodart | last post by:
Introduction Performance is the main concern to most server application developers. That’s why many of them anticipate using .NET platform to develop high performance server application regardless of the security features it provides. Microsoft Windows provides a high performance model that uses I/O completion port (IOCP) to process network events. IOCP provides best performance, but difficult to use due to lack of good code samples and...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.