Reply
Check database connection info
Old 03-15-2009, 04:38 AM Check database connection info
itHighway's Avatar
Skilled Talker

Posts: 73
Name: Zeeshan Dar
Location: GUJ
Trades: 0
Hello,

I have a form where a user provide database connection info and than click "Test" button to check if given database info is correct or not.

If database is MS Access then user provides database name and path and if it is Sql Server than user provides sql server connection info.

Is there any command or script that check database connection info and find whether info provided by user is correct or not?


Thank you,
itHighway is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 03-15-2009, 05:52 PM Re: Check database connection info
chrishirst's Avatar
Super Moderator

Posts: 22,214
Location: Blackpool. UK
Trades: 0
Error handling in ASP VbScript is a little primitive but effective if you know how to use it. This shows how for an Access DB with a connection string.
Code:
dim m_oConn   
dim m_oConnString

set m_oConn=server.createobject("ADODB.connection")
'build your connection here

m_oConnString = "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source= " & server.mappath("/db/access.mdb")


on error resume next ' set error trapping 
m_oConn.Open m_oConnString ' try to open the connection 

if err.number <> 0 then
'handle the error here
' this will just print out the error description
  response.write "Whoops! This happened <br>"
  response.write err.description
else
  response.write "Whoo Hoo!!"
end if
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Check database connection info
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.10173 seconds with 13 queries