1. Ramón San Félix Ramón
  2. SnapDevelop
  3. Friday, 25 September 2020 10:36 AM UTC

Hi

I'm using PowerScript Dynamic DataStore like this:

//----------------------------------------------PowerBuilder Example ------------------------------------------

long ll_row, ll_rowCount
String ls_sql
String ls_Syntax, ls_error, ls_cliente
DataStore ds_ms

ds_ms = CREATE DataStore

ls_sql = "SELECT empresa, anyo, serie, factura, cliente, importe "+&
            "FROM venfac "+&
            "WHERE empresa = '"+empresa+"' "+&
            "AND anyo = "+anyo+" " +&
            "AND serie ='"+serie+"'"

ls_Syntax = SQLCA.SyntaxFROMSQL ( ls_sql, "", ls_error )

ds_ms.Create ( ls_Syntax, ls_error )

ds_ms.SetTransObject ( SQLCA )
ds_ms.Retrieve()

ll_RowCount = ds_ms.RowCount()

for ll_row = 1 to ll_RowCount
    ls_cliente = ds_ms.object.cliente[ll_row]

   //do something
next

//------------------------------------------------------------------------------------------------------------------

And in Snapdevelop I have seen that with this method I can do the same ...

//----------------------------------------------SnapDevelop Example ------------------------------------------

var sql = @"SELECT empresa, anyo, serie, factura, cliente, importe
                  FROM venfac 
                  WHERE empresa = @empresa 
                  AND anyo = @anyo 
                  AND serie =@serie;

 var ms = _dataContext.SqlExecutor.SelectToStore<DynamicModel>(sql, empresa, anyo, serie, factura);

 var rowCount = ms.Count;

for (int row = 0; row < rowCount; row++)

{

     string cliente = ms.GetValue<string>(row, "cliente");

    //do something

}

//--------------------------------------------------------------------------------------------------------------------------

The problem is that ID marks me that in an obsolete method and I don't know which one I could replace it with. Could you give me an example to make dynamic queries of this style.

Thank you.

 

 

Accepted Answer
Ramón San Félix Ramón Accepted Answer Pending Moderation
  1. Friday, 25 September 2020 11:49 AM UTC
  2. SnapDevelop
  3. # Permalink
Ok I have remplace my code with this:

var sql = @"SELECT empresa, anyo, serie, factura, cliente, importe
                  FROM venfac 
                  WHERE empresa = @empresa 
                  AND anyo = @anyo 
                  AND serie =@serie;

 var list = _dataContext.SqlExecutor.Select<DynamicModel>(sql, empresa, anyo, serie, factura);

 var rowCount = list.Count;

for (int row = 0; row < rowCount; row++)

{

     string cliente = ms[row].GetValue<string>( "cliente");

    //do something

}

 

 

 

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 25 September 2020 11:13 AM UTC
  2. SnapDevelop
  3. # 1

Hi.

Not sure what version of SnapDevelop you are using. SelectToStore method (which was obsolete) can be replaced with Select method, as you can see in the following thread.

https://community.appeon.com/index.php/qna/q-a/replacement-for-selecttostore-method-in-snapdevelop-2-0

Andreas.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.