NetProg

 


   

NETPROG  PRESENTATION

 

  OverView
  Functionalities
  Programming
API
C Examples
  Download
Data Base example
C NetProg Programming
IP client server Connection Dialog Examples
TCP yes yes IP_PROTO_TCP TCP example
FTP yes no IP_PROTO_FTP FTP example
HTTP yes no IP_PROTO_HTTP HTTP example
SMTP yes no IP_PROTO_SMTP SMTP example
POP yes no IP_PROTO_POP POP example
DNS yes no IP_PROTO_DNS DNS example
DG yes yes IP_PROTO_DG USER_DEFINED example
IO          
STORE yes - IO_PROTO_STORE ANY  example
FIXED SIZE yes - IO_PROTO_FIOP  USER_DEFINED example
DATABASE          
ODBC yes - DB_PROTO_ODBC  DB example
ORACLE yes  -  DB_PROTO_ORACLE  DB example 
SQL/DS      DB_PROTO_SQLDS  DB example 

 

 

#include "mx.h" 
#include "db.h"

int OnReceiveAck (MXMessage* pmessage, MXCom* pcom, void* par)
{
  char Message[400];
  LONG RowsProcessed = (LONG)MXGetValue (pmessage, "RowsProcessed", 1);
  LONG SqlCode = (LONG)MXGetValue (pmessage, "SqlCode", 1);
  STRING SqlErrMsg = (STRING)MXGetValue (pmessage,"SqlErrMsg", 1);
  SHORT Stop = (SHORT)MXGetValue (pmessage, "Stop", 1);

 
  sprintf (Message, "Ack Result = %s , %d, %d\n", SqlErrMsg , RowsProcessed, SqlCode);
  printf ("Ack Result = %s , %d, %d\n", SqlErrMsg , RowsProcessed, SqlCode);
 
  return 1 ;
}


int OnReceiveSelectCountry (MXMessage* pmessage, MXCom* pcom, void* par)
{
  DWORD NbrRows = MXGetNbrRows (pmessage);
  DWORD i = 1;


  while (i <= NbrRows)
  {
    STRING id_country = MXGetValue (pmessage, "ID_COUNTRY" , i);
    STRING id_currency = MXGetValue (pmessage, "ID_CURRENCY" , i);
    STRING code_country = MXGetValue (pmessage, "CODE_UPU" , i);
    STRING code_douane = MXGetValue (pmessage, "CODE_OTHER" , i);
    STRING code_tnt = MXGetValue (pmessage, "CODE_IXD" , i);

 /* Do whatever you want */

    i++;
  }

  return 1;




void main ()

{

   MX mx;
   MXMessage* pmessage;
   MXCom* DBCom;

/* Initialize MX manager */

   MXInit (&mx, MXSERVER, NULL, NULL, 0, NULL);

/* Connect to database */


  
DBCom = MXOpenBase (&mx, "MyDataBase","UserName", "PassWord",  80, DBPROTO_ODBC, TRUE);
  if (!DBCom) return;

  MXAddComCallBack (&mx, DBCom, "DB", "AckStatement" , MXONRECV, OnReceiveAck, NULL);
  MXAddComCallBack(pmx, dbclient, "DB", "SelectCountries", MXONRECV, OnReceiveSelectCountry, dbclient);

   
/*Load countries from table country */

 

  {

    BYTE TreatmentType = OSSEQUENTIALTREATMENT; 
    DWORD Every = 1000; 
    DWORD MaxRows = 1300; 

/* put message in queue */

    pmessage = MXPutMessage(&mx,"DB", "ExecuteQuery"); 
 
    MXSetValue (pmessage, "TreatmentType", 1, &TreatmentType);
    MXSetValue (pmessage, "Every", 1, &Every);
    MXSetValue (pmessage, "MaxRows", 1, &MaxRows);
    MXSetValue (pmessage, "Name", 1, "SelectCountries");
    MXSetValue (pmessage, "SqlStatement", 1, "SELECT * FROM country");
  }

 

  MXDispatchEvents (&mx, 0);

  MXEnd (&mx);

}