TableAdapter Insert Error

B

Barry

Hi

I have the following code

dsOrdersTableAdapters.OrdersTableAdapter ota = new
MyNamespace.dsOrdersTableAdapters.OrdersTableAdapter();
conn.Open();
ota.Connection = conn;
ota.Insert(1, " " , 1); // The number is fields is over 70

I get the following error at the ota.Insert(???) point

"Cannot evaluate expression because a thread is stopped at a point where
garbage collection is impossible, possibly because the code is optimized."

Does anyone know how to solve this problem

TIA
Barry
 
C

Cowboy \(Gregory A. Beamer\)

Barry said:
Hi

I have the following code

dsOrdersTableAdapters.OrdersTableAdapter ota = new
MyNamespace.dsOrdersTableAdapters.OrdersTableAdapter();
conn.Open();
ota.Connection = conn;
ota.Insert(1, " " , 1); // The number is fields is over 70

I get the following error at the ota.Insert(???) point

"Cannot evaluate expression because a thread is stopped at a point where
garbage collection is impossible, possibly because the code is optimized."

Does anyone know how to solve this problem

If I had to guess, the number of fields is what is pounding you. One thing I
have done with the Table Adapter is revamp the insert. I noticed you were
also having some issues with nullable bit fields, etc., so the methodology
might help you:
http://tinyurl.com/5cfaeb

Just take a look at the entry and see if you like the pattern. The code gen
is very simple to create and I can post about it later.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
B

Barry

Hi

I had originally written the code to insert data using the traditional
coding style

OleDbCommand cmd = new OleDbCommand(conn, "Insert Into Orders ( ....) Values
(...)")
cmd.Parameters.AddWithValues("@field1", "Some Value");
cmd.ExecuteNonQuery();

which was too stressful for updating, should i need to add or delete some
fields, hence i was tring to use datasets in VS2005, after some trial and
error i managed to get it working using some of the datasets methods like

Add[TableName}Row
Update etc.

Thanks for your hints, i will take a close look at the code from the webpage
you mentioned.
 
B

Barry

This is an update to my original message

The actual field count is 131 not 70

The table is a part of a database of a product sold by Stone Edge
Technologies, this product allows import of data from shopping carts of
various sources like Yahoo, Amazon, Aspdotnetstorefont etc, hence the large
number of fields i suppose.



Barry said:
Hi

I had originally written the code to insert data using the traditional
coding style

OleDbCommand cmd = new OleDbCommand(conn, "Insert Into Orders ( ....)
Values (...)")
cmd.Parameters.AddWithValues("@field1", "Some Value");
cmd.ExecuteNonQuery();

which was too stressful for updating, should i need to add or delete some
fields, hence i was tring to use datasets in VS2005, after some trial and
error i managed to get it working using some of the datasets methods like

Add[TableName}Row
Update etc.

Thanks for your hints, i will take a close look at the code from the
webpage you mentioned.


Cowboy (Gregory A. Beamer) said:
If I had to guess, the number of fields is what is pounding you. One
thing I have done with the Table Adapter is revamp the insert. I noticed
you were also having some issues with nullable bit fields, etc., so the
methodology might help you:
http://tinyurl.com/5cfaeb

Just take a look at the entry and see if you like the pattern. The code
gen is very simple to create and I can post about it later.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top