May 28, 2013 at 11:41 AM
Edited May 28, 2013 at 11:45 AM
I have a DataTable filled with data, there are columns called "ALIASNUM" and "VALUE".
I'm trying to get the values for all items in "ALIASNUM" column and put it in "VALUE" column.

this is my code:
NDde.Client.DdeClient client = new NDde.Client.DdeClient("TR1EMCodeEmulator", "Command");
DataRow[] rowList = dataTable1.Select("ALIASNUM > 0 ");
foreach (DataRow dr in rowList)
     string alias = dr["ALIASNUM"].ToString();
     string currentValue = client.Request(alias, 60000);
     dr["VALUE"] = currentValue;
This code is working fine, but I want to use StartAdvise to make these values a realtime values, how can I do it?
Jun 14, 2013 at 1:02 PM
Edited Jun 14, 2013 at 1:05 PM
This is how I implemented it .
I began the advise, and subscribed to the advise event.
void MainFunction()
            //setup the dde client
            NDde.Client.DdeClient client = new NDde.Client.DdeClient("TR1EMCodeEmulator", "Command");

           //begin the advise
           client.StartAdvise(alias, 1, true, 60000);
           //subscribe to the advise event
           client.Advise += client_Advise;
Then under the callback just use the event argument to update your table or do what you want with the
real time value of the item you've advised.
//Make sure to use the DdeAdviseEventArgs to pass the advise event from the ndde client
private void client_Advise(object sender, DdeAdviseEventArgs args)

//handle the item.
// I used a struct to hold the data from the args argument
// myItem.Name = args.Item;
// myItem.State = args.State;
// myItem.Value = args.Text;
// myItem.Format = args.Format;
// myItem.Data = args.Data;

//you might want to do the following
//use the args.item to search were it is in your table
//then update your table with args.value