Forum Discussion

Alina's avatar
Alina
Occasional Contributor
12 years ago

Back-End testing

Hi,

I am trying to import data into a SQL database from the back end so that this can be retreived in the front end. i.e. Import a list of products in SQL Tables, that can be viewwed/searhed for in the front end U.I.



Any ideas as to the best way to go about this?

P.S I am creating scripts in VBScript

5 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    If the backend data is already in an excel spreadsheet you can use an ADO connection to access, compare, run scripts based on the data etc. I'd suggest reading this bit:

    http://support.smartbear.com/viewarticle/56911/



    Or you can declare the connection yourself (JScript example):





    //create connection

    var xlsPath = 'C:\Somespreadsheet.XLS';


    var ecommand = new ActiveXObject("ADODB.command");


    var econnection = new ActiveXObject("ADODB.connection");


    econnection.connectionstring = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + xlsPath + ";Extended Properties=Excel 8.0;User ID=admin;Password=''";


    econnection.open();

    ecommand.ActiveConnection = econnection;



    //read data


    var rdr = eselect("SELECT * FROM [Sheet1$]");


     for (;!rdr.EOF;rdr.MoveNext()){


      Log.Message(rdr(0).Value); //read first column

      Log.Message(rdr(1).Value); //read second column


      }


     rdr.close();


     rdr = null;




    (VBS example with builtin method):





    Dim xlsPath


    xlsPath = "C:\Somesheet.XLS"


    Set MyConnection = ADO.CreateADOCommand


    MyConnection.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & xlsPath & ";Extended Properties=Excel 8.0;User ID=admin;Password=''"


    MyConnection.CommandText = "SELECT * From [Sheet1]"


    Set rdr = MyConnection.Execute


    While Not rdr.EOF


     Column1 = rdr(0)


     Column2 = rdr(1)


     rdr.MoveNext


    Wend




  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    I also forgot to add that you can use this same method with an ADO connection to insert the data into your SQL database for the front end. Hope that helps! :)
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    How are you getting data from the backend? Another SQL Database or...?

    If it is an SQL database that the backend is writing to I would probably just cut out the middle man and read it into an array via ADO connection.

  • Alina's avatar
    Alina
    Occasional Contributor
    Hi,

    Its via an Excel spreadsheet...

    Im not sure on how this is done..

    any help will be mostly appreciated.



    thanks
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    I also forgot to add that you can use this same method with an ADO connection to insert the data into your SQL database for the front end. Hope that helps! :)