Creating a SalesLogix Table ID in Visual C++ .NET

I was asked how to create a table ID using C++ & .NET – I thought it was a worth while thing to post here. Not really that different from the post I made a while back about creating an ID in C#, just a few syntactical changes and voíla!


OleDbConnection* conn = new OleDbConnection(_connstring);
try
{
    conn->Open();
    OleDbCommand* cmd = new OleDbCommand("slx_dbids('account', 1)", conn);
    // place new ID in a textbox
    textBox1->Text = cmd->ExecuteScalar()->ToString();
}
catch (char* ex)
{
    MessageBox::Show(ex);
}
conn->Dispose();

One thing to note here is that the connection string must be via the SalesLogix provider (See Understanding the SalesLogix OLEDB Connection String)

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

1 Comment

  1. Sure that will work, but I’d recommend only using that in cases where you are returning more than one ID value (ie: the second parameter). No need for the added overhead of the datareader for just returning a single ID value. In case of a scalar return, use something geared for just that, which is of course what the ExecuteScalar method of the command is for. Not only that but you’re relying on the calling code to close the datareader (and therefore the connection as well). Know what I mean?

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!