db connection function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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/...16-3271-42C2-B138-2891102590AD&displaylang=en


Bobby Ryzhy
bobby @ domain below
http://weekendtech.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top