PC Review


Reply
Thread Tools Rate Thread

DataSet Tables into Access tables with Oledb?

 
 
Nevyn Twyll
Guest
Posts: n/a
 
      1st Sep 2004
I've got several datatables in a dataset that I've filled programattically.
The structure of the datatables match the structure of tables in an access
database.

What is an easy, programmatic way to insert all those datatable records into
the tables in Access without manually generating parameterized
InsertCommands for an OleDBDataAdapter?

I tried the following using an OleDbCommandBuilder to try and build the
InsertCOmmand,, and it generated an error "Microsoft JET Database Engine:
Operation must use an updateable query."


Dictionary.ECMDBDataset.MyDataTable dtMyTable;
OleDbConnection odbConn;

<...>

OleDbDataAdapter odbadapt = new OleDbDataAdapter();


odbadapt.SelectCommand = new OleDbCommand("SELECT Myfield1, Myfield2 From
[MyDataTable];", odbConn );

OleDbCommandBuilder cb = new OleDbCommandBuilder(odbadapt);

odbadapt.InsertCommand = cb.GetInsertCommand();

odbadapt.Update(dtTableList);


Help?


 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      1st Sep 2004
Hi Nevyn,

You might drag&drop table from Server Explorer to the form - it will
autogenerate an adapter for you.
Other way: you might try using my template (for free utility CodeSmith) to
autogenerate the adapter:
http://www.rthand.com/DesktopModules...ID=7&mid=10244

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com


"Nevyn Twyll" <(E-Mail Removed)> wrote in message
news:%23n7S6%23%(E-Mail Removed)...
> I've got several datatables in a dataset that I've filled
> programattically.
> The structure of the datatables match the structure of tables in an access
> database.
>
> What is an easy, programmatic way to insert all those datatable records
> into the tables in Access without manually generating parameterized
> InsertCommands for an OleDBDataAdapter?
>
> I tried the following using an OleDbCommandBuilder to try and build the
> InsertCOmmand,, and it generated an error "Microsoft JET Database Engine:
> Operation must use an updateable query."
>
>
> Dictionary.ECMDBDataset.MyDataTable dtMyTable;
> OleDbConnection odbConn;
>
> <...>
>
> OleDbDataAdapter odbadapt = new OleDbDataAdapter();
>
>
> odbadapt.SelectCommand = new OleDbCommand("SELECT Myfield1, Myfield2 From
> [MyDataTable];", odbConn );
>
> OleDbCommandBuilder cb = new OleDbCommandBuilder(odbadapt);
>
> odbadapt.InsertCommand = cb.GetInsertCommand();
>
> odbadapt.Update(dtTableList);
>
>
> Help?
>



 
Reply With Quote
 
Nevyn Twyll
Guest
Posts: n/a
 
      1st Sep 2004
I can't seem to use the templates on your website - they download without a
file extension, and when i try to open them as a .cst in CodeSmith, it
generates an error.

Help?

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:e9LAoL$(E-Mail Removed)...
> Hi Nevyn,
>
> You might drag&drop table from Server Explorer to the form - it will
> autogenerate an adapter for you.
> Other way: you might try using my template (for free utility CodeSmith) to
> autogenerate the adapter:
> http://www.rthand.com/DesktopModules...ID=7&mid=10244
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
> www.rthand.com
>
>
> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
> news:%23n7S6%23%(E-Mail Removed)...
>> I've got several datatables in a dataset that I've filled
>> programattically.
>> The structure of the datatables match the structure of tables in an
>> access database.
>>
>> What is an easy, programmatic way to insert all those datatable records
>> into the tables in Access without manually generating parameterized
>> InsertCommands for an OleDBDataAdapter?
>>
>> I tried the following using an OleDbCommandBuilder to try and build the
>> InsertCOmmand,, and it generated an error "Microsoft JET Database Engine:
>> Operation must use an updateable query."
>>
>>
>> Dictionary.ECMDBDataset.MyDataTable dtMyTable;
>> OleDbConnection odbConn;
>>
>> <...>
>>
>> OleDbDataAdapter odbadapt = new OleDbDataAdapter();
>>
>>
>> odbadapt.SelectCommand = new OleDbCommand("SELECT Myfield1, Myfield2 From
>> [MyDataTable];", odbConn );
>>
>> OleDbCommandBuilder cb = new OleDbCommandBuilder(odbadapt);
>>
>> odbadapt.InsertCommand = cb.GetInsertCommand();
>>
>> odbadapt.Update(dtTableList);
>>
>>
>> Help?
>>

>
>



 
Reply With Quote
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      1st Sep 2004
Hi,

Try running CodeSmith and open it from within CodeSmith.
It is a text file afterall :-)

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Nevyn Twyll" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I can't seem to use the templates on your website - they download without a
>file extension, and when i try to open them as a .cst in CodeSmith, it
>generates an error.
>
> Help?
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:e9LAoL$(E-Mail Removed)...
>> Hi Nevyn,
>>
>> You might drag&drop table from Server Explorer to the form - it will
>> autogenerate an adapter for you.
>> Other way: you might try using my template (for free utility CodeSmith)
>> to autogenerate the adapter:
>> http://www.rthand.com/DesktopModules...ID=7&mid=10244
>>
>> --
>> Miha Markic [MVP C#] - RightHand .NET consulting & development
>> miha at rthand com
>> www.rthand.com
>>
>>
>> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
>> news:%23n7S6%23%(E-Mail Removed)...
>>> I've got several datatables in a dataset that I've filled
>>> programattically.
>>> The structure of the datatables match the structure of tables in an
>>> access database.
>>>
>>> What is an easy, programmatic way to insert all those datatable records
>>> into the tables in Access without manually generating parameterized
>>> InsertCommands for an OleDBDataAdapter?
>>>
>>> I tried the following using an OleDbCommandBuilder to try and build the
>>> InsertCOmmand,, and it generated an error "Microsoft JET Database
>>> Engine: Operation must use an updateable query."
>>>
>>>
>>> Dictionary.ECMDBDataset.MyDataTable dtMyTable;
>>> OleDbConnection odbConn;
>>>
>>> <...>
>>>
>>> OleDbDataAdapter odbadapt = new OleDbDataAdapter();
>>>
>>>
>>> odbadapt.SelectCommand = new OleDbCommand("SELECT Myfield1, Myfield2
>>> From [MyDataTable];", odbConn );
>>>
>>> OleDbCommandBuilder cb = new OleDbCommandBuilder(odbadapt);
>>>
>>> odbadapt.InsertCommand = cb.GetInsertCommand();
>>>
>>> odbadapt.Update(dtTableList);
>>>
>>>
>>> Help?
>>>

>>
>>

>
>



 
Reply With Quote
 
Nevyn Twyll
Guest
Posts: n/a
 
      2nd Sep 2004
Yeah, I did. It generates an error.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OZ$(E-Mail Removed)...
> Hi,
>
> Try running CodeSmith and open it from within CodeSmith.
> It is a text file afterall :-)
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
> www.rthand.com
>
> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I can't seem to use the templates on your website - they download without
>>a file extension, and when i try to open them as a .cst in CodeSmith, it
>>generates an error.
>>
>> Help?
>>
>> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
>> news:e9LAoL$(E-Mail Removed)...
>>> Hi Nevyn,
>>>
>>> You might drag&drop table from Server Explorer to the form - it will
>>> autogenerate an adapter for you.
>>> Other way: you might try using my template (for free utility CodeSmith)
>>> to autogenerate the adapter:
>>> http://www.rthand.com/DesktopModules...ID=7&mid=10244
>>>
>>> --
>>> Miha Markic [MVP C#] - RightHand .NET consulting & development
>>> miha at rthand com
>>> www.rthand.com
>>>
>>>
>>> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
>>> news:%23n7S6%23%(E-Mail Removed)...
>>>> I've got several datatables in a dataset that I've filled
>>>> programattically.
>>>> The structure of the datatables match the structure of tables in an
>>>> access database.
>>>>
>>>> What is an easy, programmatic way to insert all those datatable records
>>>> into the tables in Access without manually generating parameterized
>>>> InsertCommands for an OleDBDataAdapter?
>>>>
>>>> I tried the following using an OleDbCommandBuilder to try and build the
>>>> InsertCOmmand,, and it generated an error "Microsoft JET Database
>>>> Engine: Operation must use an updateable query."
>>>>
>>>>
>>>> Dictionary.ECMDBDataset.MyDataTable dtMyTable;
>>>> OleDbConnection odbConn;
>>>>
>>>> <...>
>>>>
>>>> OleDbDataAdapter odbadapt = new OleDbDataAdapter();
>>>>
>>>>
>>>> odbadapt.SelectCommand = new OleDbCommand("SELECT Myfield1, Myfield2
>>>> From [MyDataTable];", odbConn );
>>>>
>>>> OleDbCommandBuilder cb = new OleDbCommandBuilder(odbadapt);
>>>>
>>>> odbadapt.InsertCommand = cb.GetInsertCommand();
>>>>
>>>> odbadapt.Update(dtTableList);
>>>>
>>>>
>>>> Help?
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Nevyn Twyll
Guest
Posts: n/a
 
      2nd Sep 2004
Yeah, I did. It generates an error.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OZ$(E-Mail Removed)...
> Hi,
>
> Try running CodeSmith and open it from within CodeSmith.
> It is a text file afterall :-)
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
> www.rthand.com
>
> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I can't seem to use the templates on your website - they download without
>>a file extension, and when i try to open them as a .cst in CodeSmith, it
>>generates an error.
>>
>> Help?
>>
>> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
>> news:e9LAoL$(E-Mail Removed)...
>>> Hi Nevyn,
>>>
>>> You might drag&drop table from Server Explorer to the form - it will
>>> autogenerate an adapter for you.
>>> Other way: you might try using my template (for free utility CodeSmith)
>>> to autogenerate the adapter:
>>> http://www.rthand.com/DesktopModules...ID=7&mid=10244
>>>
>>> --
>>> Miha Markic [MVP C#] - RightHand .NET consulting & development
>>> miha at rthand com
>>> www.rthand.com
>>>
>>>
>>> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
>>> news:%23n7S6%23%(E-Mail Removed)...
>>>> I've got several datatables in a dataset that I've filled
>>>> programattically.
>>>> The structure of the datatables match the structure of tables in an
>>>> access database.
>>>>
>>>> What is an easy, programmatic way to insert all those datatable records
>>>> into the tables in Access without manually generating parameterized
>>>> InsertCommands for an OleDBDataAdapter?
>>>>
>>>> I tried the following using an OleDbCommandBuilder to try and build the
>>>> InsertCOmmand,, and it generated an error "Microsoft JET Database
>>>> Engine: Operation must use an updateable query."
>>>>
>>>>
>>>> Dictionary.ECMDBDataset.MyDataTable dtMyTable;
>>>> OleDbConnection odbConn;
>>>>
>>>> <...>
>>>>
>>>> OleDbDataAdapter odbadapt = new OleDbDataAdapter();
>>>>
>>>>
>>>> odbadapt.SelectCommand = new OleDbCommand("SELECT Myfield1, Myfield2
>>>> From [MyDataTable];", odbConn );
>>>>
>>>> OleDbCommandBuilder cb = new OleDbCommandBuilder(odbadapt);
>>>>
>>>> odbadapt.InsertCommand = cb.GetInsertCommand();
>>>>
>>>> odbadapt.Update(dtTableList);
>>>>
>>>>
>>>> Help?
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Nevyn Twyll
Guest
Posts: n/a
 
      2nd Sep 2004
Okay, I'm lame but I'm not that lame.
It causes a parse error on opening.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OZ$(E-Mail Removed)...
> Hi,
>
> Try running CodeSmith and open it from within CodeSmith.
> It is a text file afterall :-)
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
> www.rthand.com
>
> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I can't seem to use the templates on your website - they download without
>>a file extension, and when i try to open them as a .cst in CodeSmith, it
>>generates an error.
>>
>> Help?
>>
>> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
>> news:e9LAoL$(E-Mail Removed)...
>>> Hi Nevyn,
>>>
>>> You might drag&drop table from Server Explorer to the form - it will
>>> autogenerate an adapter for you.
>>> Other way: you might try using my template (for free utility CodeSmith)
>>> to autogenerate the adapter:
>>> http://www.rthand.com/DesktopModules...ID=7&mid=10244
>>>
>>> --
>>> Miha Markic [MVP C#] - RightHand .NET consulting & development
>>> miha at rthand com
>>> www.rthand.com
>>>
>>>
>>> "Nevyn Twyll" <(E-Mail Removed)> wrote in message
>>> news:%23n7S6%23%(E-Mail Removed)...
>>>> I've got several datatables in a dataset that I've filled
>>>> programattically.
>>>> The structure of the datatables match the structure of tables in an
>>>> access database.
>>>>
>>>> What is an easy, programmatic way to insert all those datatable records
>>>> into the tables in Access without manually generating parameterized
>>>> InsertCommands for an OleDBDataAdapter?
>>>>
>>>> I tried the following using an OleDbCommandBuilder to try and build the
>>>> InsertCOmmand,, and it generated an error "Microsoft JET Database
>>>> Engine: Operation must use an updateable query."
>>>>
>>>>
>>>> Dictionary.ECMDBDataset.MyDataTable dtMyTable;
>>>> OleDbConnection odbConn;
>>>>
>>>> <...>
>>>>
>>>> OleDbDataAdapter odbadapt = new OleDbDataAdapter();
>>>>
>>>>
>>>> odbadapt.SelectCommand = new OleDbCommand("SELECT Myfield1, Myfield2
>>>> From [MyDataTable];", odbConn );
>>>>
>>>> OleDbCommandBuilder cb = new OleDbCommandBuilder(odbadapt);
>>>>
>>>> odbadapt.InsertCommand = cb.GetInsertCommand();
>>>>
>>>> odbadapt.Update(dtTableList);
>>>>
>>>>
>>>> Help?
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to loop through all tables in an Access dataset =?Utf-8?B?Y2h1bg==?= Microsoft Access VBA Modules 6 20th Nov 2007 09:27 PM
Access to tables in dataset DesCF Microsoft ADO .NET 5 12th Jul 2007 05:53 PM
Joining FoxPro Tables in Microsoft Access via OLEDB TerryJayFoster@gmail.com Microsoft Access External Data 6 12th Jul 2007 01:03 PM
How to update dataset.Tables["tab1"] from records in dataset.Tables["tab2"]? AndiSHFR Microsoft C# .NET 1 12th Jan 2006 06:41 AM
Creating archive tables for Access tables joined to Sybase tables =?Utf-8?B?QXJjaGl2ZSBUYWJsZXM=?= Microsoft Access External Data 0 11th Jan 2006 10:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:03 AM.