2 Replies Latest reply: Jul 28, 2010 10:48 AM by Helmut Winkler RSS

    Trying to write data on a remote SQL Server db with ADO object and OLEDB

      Hello,

      in my QlikView application I need to upload data from txt/csv files (previously uploaded) and write them on a remote SQL Server DB using OLEDB driver.

      Reading this forum I found the utilisation of ADO technology as unique solution, inserting it into a macro.

      I tried to create a basic vbscript function to insert one record in db.

      Here's my code:

       


      sub dbInsert
      dim sConn, oRS, sSQL

      set sConn = CreateObject("ADODB.Connection")
      url = "Provider=sqloledb;Data Source=server_name;Initial Catalog=db_name;UserId=xxxx;Password=xxxx"
      sConn.open url
      set oRS =CreateObject("ADODB.Recordset")
      sSQL="INSERT INTO STG.STG_PROVA_INSERT (FATTURA_RIGA_ID, FATTURA_ID, PRODOTTO_ID, CONTRATTO_ID, PUNTO_ID, VERSIONE_ID, NUMERO_FISCALE, RIGA_CD) VALUES (0,0,0,0,0,0,"","")"
      oRS.Open sSQL, sConn, adOpenDynamic, adLockOptimistic, adCmdUnspecified
      rem set oRS = sConn.execute(sSQL)
      oRS.close
      set oRS = Nothing
      sConn.commit
      sConn.close
      set sConn = Nothing
      end sub


       

      The execution fails with command "sConn.open url", I think because the compiler doesn't solve "CreateObject("ADODB.Connection")" call.

       

      Any clues? Tips? Tricks? Would really appreciate it!

       

       

      Thanks a lot,

       

      Alessandro

      erv