typed-dataset initializer problem with C# windows app.

Posted by Eyla on Stack Overflow See other posts from Stack Overflow or by Eyla
Published on 2010-04-07T23:12:38Z Indexed on 2010/04/07 23:33 UTC
Read the original article Hit count: 341

Filed under:
|

Greetings,

I'm working in windows application using C#.

I have typed-dataset called packetsDBDataSet and it has table adapter called packetsTableAdapter with method to insert data called InsertPackets().

when I want to insert new data I used a code that I used before with asp.net page and it was working ok but not I'm getting error.

here is the code:

public packetsDBDataSetTableAdapters.packetsTableAdapter ds = new packetsDBDataSetTableAdapters.packetsTableAdapter();

public packetsDBDataSet.packetsDataTable insert = ds.InsertPackets(); 

and here is the error:

Error 1 A field initializer cannot reference the non-static field, method, or property 'Packets.Form1.ds' C:\Users\Ali\Documents\Visual Studio 2008\Projects\Packets-3\Packets\Packets\Form1.cs 26 59 Packets

I already included to my project: using Packets; using Packets.packetsDBDataSetTableAdapters;

please advice to solve this problem.

Update :

I also tried :

public packetsDBDataSetTableAdapters.packetsTableAdapter ds = new packetsDBDataSetTableAdapters.packetsTableAdapter();

ds.InsertPackets("1","2","3");

and I'm getting this error:

Error 1 Invalid token '(' in class, struct, or interface member declaration C:\Users\Ali\Documents\Visual Studio 2008\Projects\Packets-3\Packets\Packets\Form1.cs 28 29 Packets

© Stack Overflow or respective owner

Related posts about c#

Related posts about strongly-typed-dataset