Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


DSN database connection query

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,34225
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> DSN database connection query
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 DSN database connection query - 5/5/2006 1:50:46 AM   
  izzyonstage

 

Posts: 5
Score: 0
Joined: 5/5/2006
Status: offline
Hi,

Can anyone tell how to findout what my Database driver is from a DSN connection, as i am trying to write a vbscript that will allow easy connection to any database using any type of connection (DSN or DSN-less) but also format the sql query accordingly, but i cant see any way to determin what database is being accessed when using a DSN connection.

Please can anyone help me?
 
 
Post #: 1
 
 RE: DSN database connection query - 5/6/2006 2:39:25 AM   
  ehvbs

 

Posts: 2065
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi izzyonstage,

although I'm not working with ASP your project looks very interesting to me. I'd
really would like to collaborate with you concerning the database aspect of your
project. For starters - this code


      

demonstrates, how to get information from the Connectionstring and/or the Properties
of an ADODB.Connection. You'll have to change aTests() according to your system, of course.
If you think something like this approach could solve your problem, I'd gladly discuss the
details/enhancements necessary.

ehvbs

(in reply to izzyonstage)
 
 
Post #: 2
 
 RE: DSN database connection query - 5/6/2006 11:25:44 PM   
  izzyonstage

 

Posts: 5
Score: 0
Joined: 5/5/2006
Status: offline
hi ehvbs,

thanks for replying, I am willing to accept any help with the creation of this script. My main intention is to make it easyer for people to connect to databases on a webpage and perform sql queries without knowing sql. Initially i am writing this in vbscript, I am also working towards a PHP and Perl version. So no matter what type of system a person has they will be able to use this script.

Basically, at the moment i have got my script to connect and query MySQL, Access and MSSQL. But now i am looking deeper, and am trying to make it easy for anyone to use. So i thought why not add the use of DSN connections as well, But the only problem i found was i could not detect which database was being connected to in order to format the sql correctly.

I found the script you posted very interesting, Can i ask you to explain it in some detail, As the working I have done on my script so far is very different to the layout of yours. I managed to pickup most of what was there, but not all. Also just to let you know, I have only been into programming for the last few mounths.

The way the script works at the moment is as a *.vbs file which is included into the web page being created, which contains 1 function and about 12 subs at present.the function is used for when a recordset is to be returned to the browser, the sub to work thorough each part of the connection and sql creation. All the web page writer has to do is initiallise a few arrays (1 for each sql query) and 2 variables used for getting the number of columns and number of rows in the recordset.

Hope to hear from you again soon.

izzyonstage

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: DSN database connection query - 5/7/2006 6:43:14 PM   
  ehvbs

 

Posts: 2065
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi izzyonstage,

thanks for the info about your project. It looks even more interesting for
me now (especially the word "Perl"!).

My script should be used from a command line. It uses the even numbered
elements of aTests to open ADODB.Connections. For each connection it
puts the information from the Connectionstring and the properties of
the connection into a dictionary for easy questioning. Parsing the
connectionstring is unduly complicated by those !@§$ extended properties,
but that can't be avoided if the connectionstring is to be used. (Will
the properties alone give you all the information you need?)
The "If .. ElseIf .. Else ... End If" is a clumsy but easy to modify/
enhance method to classify the connection. I neglected the versions,
but this could be added, if you need to distinguish between MySQL 3.32
and 5.0. The test code compares the resulting classification string
against the expected result (odd numbered items of aTests). If you
add a pair to aTests that isn't provided for in the getDBD() function,
you'll get a dump of the dictionary (tip: use cscript xxx.vbs >tmp.txt
for easy checking), that can be used to add another ElseIf clause.

I *think* when you got your recordset you can use
   Select getDBD( oRS.Connection )
     Case "Microsoft.Jet.OLEDB"
        ...
     Case "ODBC/DBASE"
        ...
     ...
   End Select
to do driver specific things.

I would be very interested in your method/code to display the recordset
(I use a datagrid in my (client) HTML/HTA code, which leads to catastrophies
on 'normal' (non development) computers).

Do you think, your HTML code and my command line code could meet in an
HTA application?

(in reply to izzyonstage)
 
 
Post #: 4
 
 RE: DSN database connection query - 5/8/2006 2:02:19 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Sounds like a very useful project. Just so you know, PERL already has several generic DB access interfaces along with specific interfaces for any DB I've ever heard of and a buttload that I haven't.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ehvbs)
 
 
Post #: 5
 
 RE: DSN database connection query - 5/10/2006 1:27:36 AM   
  izzyonstage

 

Posts: 5
Score: 0
Joined: 5/5/2006
Status: offline
Hi ehvbs,

I have reviewed your script and am just seeing if i can re-write parts to add to my current coding for the best performance, also your script has enspired me into a slight re-write of my own code for better use and implementation. In particular using functions, as previously i was using subs. I am glad you are still interested. One question for you is, Can you tell me what HTA means, as as far as i know all my vbscripting is all HTML based.

Just as a taster here is my old non re-written code (which was only for MySQL) which show prety much how i am trying to achieve things: -


      

Now I know this code is very messy but i put this together just to give me easy functionallity. But now i am developing this to all forms of database and adding all possible extras like user, database and table creation modifications and removals. Also in my new re-written code i am going to add an extra feature to the table name value, which is "Table Qualifyer" which i have found usefull where i work. I am a new b DBA you see, and the database we use has been mounted with a table qualifyer. Recently i have also found a list of all the different types of database connection to all the different types of database available, which I intend to add to this script. Also just to add i am also working on a way that a person call call this script but only enter the data that is relevant, so as not to have so many empty speach marks when calling the script


also Hi to ebgreen, the main reason for me wanting to do it with PERL as well, is because if i can put all the coding together as one package and anyone who uses it can use any programming language they want with the same style of coding to call the script. I mean, I find it a pain when writing one page with one style of code then having to write exactly the same thing but in a different way for another.


I am also thinking now of adding a JavaScript version aswell. once all together it can be available to anyone who just wants a script to aid quick development of database driven websites. If this script has the ability for even more development into other uses then so be it. The wider variety this script has the better.

I know my programming is probably terible but i am just doing thing from scratch and looking at this from an "I dont know how this works" point of view. If you have anythingthat might make any part of this code better then please dont hesitate to post it.

P.S. Will post new re-written script as soon as i have finnished.

(in reply to ehvbs)
 
 
Post #: 6
 
 RE: DSN database connection query - 5/10/2006 1:30:05 AM   
  izzyonstage

 

Posts: 5
Score: 0
Joined: 5/5/2006
Status: offline
One last question, how do i get from new member star to the 5 or 6 start you have all got?

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: DSN database connection query - 5/10/2006 11:36:54 PM   
  izzyonstage

 

Posts: 5
Score: 0
Joined: 5/5/2006
Status: offline
Hi again,

Have just found a website that gives loads of info on the differences between the sql statements for all the most popular databases at: - http://troels.arvin.dk/db/rdbms/.

While reading it i realised another good thing about this script.

        It will allow for all the database's mentioned (plus others when we find all the relevant coding) to have all the same functionality, where at the moment there are complete differences and 1 database can do one thing but another cant, this script will restructure the sql query to the point where the same query is used on all databases but will have the sql coding for just the specific database in question to replicate the idea of the query to be run. Also this script could be good for anyone changing from one system to another as it is all under one roof.

Then when it is all working, On to PHP and PERL. woo hoo!!!

< Message edited by izzyonstage -- 5/10/2006 11:38:45 PM >

(in reply to ehvbs)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> DSN database connection query Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts