[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

TableAdapter Insert Error

Branimir Petrovic

11/5/2008 1:21:00 PM

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


3 Answers

Cowboy

11/5/2008 3:19:00 PM

0


"Barry" <someone@somewhere.com> wrote in message
news:eCHlJl0PJHA.5076@TK2MSFTNGP02.phx.gbl...
> 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....

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/Greg...

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

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

Branimir Petrovic

11/6/2008 8:37:00 AM

0



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)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
message news:%23DLZNn1PJHA.2228@TK2MSFTNGP06.phx.gbl...
>
> "Barry" <someone@somewhere.com> wrote in message
> news:eCHlJl0PJHA.5076@TK2MSFTNGP02.phx.gbl...
>> 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....
>
> 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/Greg...
>
> or just read it:
> http://feeds.feedburner.com/Gre...
>
> ********************************************
> | Think outside the box! |
> ********************************************


Branimir Petrovic

11/8/2008 9:22:00 AM

0


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" <someone@somewhere.com> wrote in message
news:uo1for%23PJHA.3932@TK2MSFTNGP02.phx.gbl...
>
>
> 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)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
> message news:%23DLZNn1PJHA.2228@TK2MSFTNGP06.phx.gbl...
>>
>> "Barry" <someone@somewhere.com> wrote in message
>> news:eCHlJl0PJHA.5076@TK2MSFTNGP02.phx.gbl...
>>> 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....
>>
>> 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/Greg...
>>
>> or just read it:
>> http://feeds.feedburner.com/Gre...
>>
>> ********************************************
>> | Think outside the box! |
>> ********************************************
>
>