Link to home
Create AccountLog in
Avatar of rwheeler23
rwheeler23Flag for United States of America

asked on

SQL Temp tables and/or arrays VS 2008 C#

I have to write a snippet of code that will interface with an accounting program. In that program the data will be in a datagrid that I can read but not write. Using VS 2008 C# and MS SQL Server 2005 I have two questions:
1) I can extract the data from the grid and then write into a SQL temp table. Now given that multiple users can run this program at the same time, how do I insure the SQL temp table that is created is unique?
2) Instead of using a SQL temp table, is there any kind of variable array method I can use to temporarily hold the values, display them on the screen in a datagridview and then add any additional functionality?

I am trying to determine if using SQL temp table is my only choice or is there a more efficient way of handling this situation?
ASKER CERTIFIED SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of rwheeler23

ASKER

Please excuse my ignorance as I am still learning VS. As you can see below I have created the loop that will go through the datagrid of the accounting program. Now I need to extract certain values out of that grid and get it into the type of grid to which you refer. I have tried following the example you list but I not getting it right. What is the correct syntax to populate a datagrid that I can then display?

I have put two sample fields in the example:
DocAmount
DocNumber
try
            {
                /* Loop through the apply documents buffer and insert records into datalist */
                TableError err;
                decimal DocAmount;
                string DocNumber;
                

                /* Create a reference to the Apply Documents grid */
                PmApplyToOpenOpenTable PmApplyToOpenOpenTable;
                
                /* This points to the form table buffer */
                PmApplyToOpenOpenTable = Dynamics.Forms.PmApplyToMaintenance.Tables.PmApplyToOpenOpen;
                
                /* Read through the table buffer extracting a record for each open payables document */
                err = PmApplyToOpenOpenTable.GetFirst();

                while (err != TableError.EndOfTable)
                {
                    DocAmount = PmApplyToOpenOpenTable.AppliedAmount;
                    DocNumber = PmApplyToOpenOpenTable.ApplyToDocumentNumber;

                }
            }
            catch (Exception ex)
            {
                string eMsg = "002: ERROR:" + ex.Message;
                if (stackTraceWanted) eMsg += "\n" + ex.StackTrace;
                MessageBox.Show(eMsg);
            }
        }

Open in new window

By the way, I am used to using a DataGridView so what I a looking to do is to find out how to populate a data grid view with the values in this datagrid coming from the accounting program.