473,323 Members | 1,551 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,323 software developers and data experts.

db connection function

I have a sub named ConnectToDb which has my db connections commands in it.
When I call it from another page that sub routine will not execute and i can't connect to the DB via that sub.
why is it not allowing me to connect?

code:
public sub ConnectToDB()
conn.connectionstring = ConfigurationSettings.AppSettings("DB")
conn.Open
end sub

the code i'm calling it from
sub GetData()
db.ConnectToDB()

'code to call SP's and bind grids

end sub

nothing happens this way, why not?
Nov 18 '05 #1
1 1307
On Thu, 29 Jul 2004 10:57:08 -0700, "IGotYourDotNet" <IG************@discussions.microsoft.com> wrote:
I have a sub named ConnectToDb which has my db connections commands in it.
When I call it from another page that sub routine will not execute and i can't connect to the DB via that sub.
why is it not allowing me to connect?

code:
public sub ConnectToDB()
conn.connectionstring = ConfigurationSettings.AppSettings("DB")
conn.Open
end sub

the code i'm calling it from
sub GetData()
db.ConnectToDB()

'code to call SP's and bind grids

end sub

nothing happens this way, why not?

The main thing that is wrong is that you are not passing the connection object back. To save yourself ALLOT of work - use the microsoft
data block. http://www.microsoft.com/downloads/d...displaylang=en
Bobby Ryzhy
bobby @ domain below
http://weekendtech.net
Nov 18 '05 #2

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

Similar topics

9
by: mcbill20 | last post by:
Hello all. I just installed Oracle 10g developer tools on a machine running XP Pro and Office XP. Before this I had just the Oracle 9 client installed. I the previous configuration, I was able to...
2
by: Jozef | last post by:
Hello, I'm trying to create a central function that runs a connection to an SQL Server database. The connection etc works, but when I try to call it, I get an error saying "Runtime-Error 91:...
3
by: R Reyes | last post by:
Hi, I'm trying to modularize my database connections a little better and get more out of my project with less code. First check out this common dbOpen() function inside class clsDatabase. I...
2
by: Bryan | last post by:
Hello, I'm just starting to develop in asp.net and i have a question about using a database connection globally in my app. I have set up the procedures for getting all my connection string info...
4
by: Anthony England | last post by:
This is a simple question, which has been debated before, but can I ask it again with reference to a specific example? The question is basically should I close and set to nothing an ADO connection...
7
by: momo | last post by:
Hello to all, I need some help. I am looking for a database connection function that I can use in my ASP.NET site. This would be in VB.NET. What I want to be able to do is call the function and...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
1
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
0
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.