I use visual studio 2013 to create a winform app with tabaleadapter to connect with database. My problem is insert query throw a unhandled exception when it inside a loop statement.
This code work:
abcTableAdapter.InsertQuery(param1, param2, param3);
But this code throw the exception:
for (int i = 1; i < 5; i++)
{
abcTableAdapter.InsertQuery(param1, param2, param3);
}
The exception is:
An unhandled exception of type 'System.AccessViolationException' occurred in myApp.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I also have same problem with foreach
statement.
What is wrong with my code? I googled whole day, but I cannot see any solution.