Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


creating an odbc connection using vbscript

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> creating an odbc connection using vbscript
  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 >>
 creating an odbc connection using vbscript - 12/12/2007 2:39:19 AM   
  jmoulton

 

Posts: 4
Score: 0
Joined: 12/12/2007
Status: offline
Hey there, I am pretty new to vbscripting even though I have used VB in the past a few times.
I am trying to connect to an ODBC database using vbscript so that I can run a query and export this into a text file. The problem I am having at the moment is getting connected to the database. I can't seem to get the connection string right as it keeps giving me an error saying it can not find the data source and no driver was specified. I am not sure exactly what params are required so I was wondering if anyone could fill me in. THANKS!

Justin
 
 
Post #: 1
 
 RE: creating an odbc connection using vbscript - 12/12/2007 2:45:39 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Have you done any searching on the net? There are several sites that just provide connection string examples. We could also help more if you post the code that you are working with.

_____________________________

"... 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 jmoulton)
 
 
Post #: 2
 
 RE: creating an odbc connection using vbscript - 12/12/2007 4:19:32 AM   
  jmoulton

 

Posts: 4
Score: 0
Joined: 12/12/2007
Status: offline
Here is the code:
Dim ad
Dim sql_query
Dim objFSO, objOutFile
Dim intCount, i
Set objFSO = CreateObject("Scripting.FileSystemObject")     'create  and open text file
Set objOutFile = objFSO.OpenTextFile("C:\tabdelimitout.txt", 8, True)
sql_query = "SELECT * FROM MyTable"       'sql query

set ad = CreateObject("ADODB.Connection")      'create and open ODBC connection
ad.ConnectionString= "ODBC;DSN=fk32y;UID=me"
ad.Open

Set rs = ad.execute(sql_query)        'execute query
intCount = rs.Fields.Count        
do while not rs.eof         'loop to cycle through the table
for i = 1 to intCount     'loop to cycle through fields of each table and write to file
 objOutFile.Write rs.fields.item(i) & vbTab
next
objOutFile.WriteLine vbCrLf       'newline
  
loop
ad.close


Don't worry about the details with writing it to a text file, I am just working on getting the connection and then I will worry about that.
BTW, this is a relativity database. 

(in reply to jmoulton)
 
 
Post #: 3
 
 RE: creating an odbc connection using vbscript - 12/12/2007 4:26:35 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Relativity database? I've never heard of that type of DB. Do you have a link to the vendor's website?

_____________________________

"... 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 jmoulton)
 
 
Post #: 4
 
 RE: creating an odbc connection using vbscript - 12/12/2007 7:09:20 AM   
  jmoulton

 

Posts: 4
Score: 0
Joined: 12/12/2007
Status: offline
Well no, its for work, can't give out too much info sorry. Basically its Interbase though, same thing. Does that help?

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: creating an odbc connection using vbscript - 12/12/2007 8:04:48 AM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi jmoulton,

What happens, if you follow

   http://www.connectionstrings.com/?carrier=dsn

and replace

   ad.ConnectionString= "ODBC;DSN=fk32y;UID=me"

==>

   ad.ConnectionString= "DSN=fk32y;Uid=me;Pwd=;"

(in reply to jmoulton)
 
 
Post #: 6
 
 RE: creating an odbc connection using vbscript - 12/14/2007 5:18:33 AM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi jmoulton,

just in case you read answers to your questions instead of starting
new threads: connectionstrings.com has a page about Interbase

http://www.connectionstrings.com/default.aspx?carrier=interbase

Regards

ehvbs

(in reply to ehvbs)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> creating an odbc connection using vbscript 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