troubleshooting Question

how to create insert command into access db

Avatar of MarkH12518
MarkH12518 asked on
Microsoft AccessC#
3 Comments1 Solution97 ViewsLast Modified:
I now have a datatable that matches my access db fields and am able to fill the datatable from arrays in my c#. It is 200 X 242.

Now that I have the datatable I want to insert the rows of data, either one by one or batch into access. I attempted the OleCommandBuilder but do not have a primary key in the table. So I'm doing manually I suppose.

Can someone please indicate how I can Insert into my Access table?

Thank you




DataRow row;
            int ln = dtAr.Length;
            //fill rows
            try
            {
                for (int i = 0; i < sims; i++)
                {
                    row = prtab.NewRow();
                    for (int j = 0; j < ln + 2; j++)
                    {
                        if (j == 0)
                        {
                            row["tStep"] = 1;
                        }
                        else if (j == 1)
                        {
                            row["SimNum"] = i;
                        }
                        else
                        {
                            row[CrvID[j - 2].ToString() + dtAr[j - 2].ToString()] = crNs[i, j - 2];
                        }
                    }

                    prtab.Rows.Add(row);
                }
            }
ASKER CERTIFIED SOLUTION
MohitPandit

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros