creating an odbc connection using vbscript

Author Message
jmoulton

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 12/12/2007
  • Status: offline
creating an odbc connection using vbscript Wednesday, December 12, 2007 3:39 AM (permalink)
0
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
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    RE: creating an odbc connection using vbscript Wednesday, December 12, 2007 3:45 AM (permalink)
    0
    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
     
    #2
      jmoulton

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 12/12/2007
      • Status: offline
      RE: creating an odbc connection using vbscript Wednesday, December 12, 2007 5:19 AM (permalink)
      0
      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. 
       
      #3
        ebgreen

        • Total Posts : 8227
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        RE: creating an odbc connection using vbscript Wednesday, December 12, 2007 5:26 AM (permalink)
        0
        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
         
        #4
          jmoulton

          • Total Posts : 4
          • Scores: 0
          • Reward points : 0
          • Joined: 12/12/2007
          • Status: offline
          RE: creating an odbc connection using vbscript Wednesday, December 12, 2007 8:09 AM (permalink)
          0
          Well no, its for work, can't give out too much info sorry. Basically its Interbase though, same thing. Does that help?
           
          #5
            ehvbs

            • Total Posts : 3321
            • Scores: 110
            • Reward points : 0
            • Joined: 6/22/2005
            • Location: Germany
            • Status: offline
            RE: creating an odbc connection using vbscript Wednesday, December 12, 2007 9:04 AM (permalink)
            0
            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=;"
             
            #6
              ehvbs

              • Total Posts : 3321
              • Scores: 110
              • Reward points : 0
              • Joined: 6/22/2005
              • Location: Germany
              • Status: offline
              RE: creating an odbc connection using vbscript Friday, December 14, 2007 6:18 AM (permalink)
              0
              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



               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • 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
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9