run Insert/Delete DataAdapter commands?

R

Rich

Hello,

I have an oleDBDataAdapter (da1) which gets data from an
Access mdb and fills a dataset (ds1) with integer data
from "tbl1" in Access. Data displays in textboxes on a
form. The textboxes are bound to columns in the dataset.
This works correctly. I have been struggling with
invoking da1.Update(ds1, "tbl1") and with help from the
group here have overcome this obstacle (many thanks for
the help). But I need to be able to Insert and Delete
from the same dataset. Do I have to populate the
parameters in da1?

'''''''''''Insert routine
Dim txtCol As TextBox() = New Textbox(){txt0, txt1, txt2}
Dim txt As Textbox
For Each txt in txtCol
da1.InsertCommand.Parameters(i).Value = txtCol(i).Text
Next
da1.Update(ds1, "tbl1")

Note: do I have to do some casting with txtCol
(i).Text? "tbl1" fields are all integer fields and the
data in the form is all integer data.

And then for Delete

da1.DeleteCommand.Parameters("fld0").Value = txt0.Text
da1.Update(ds1, "tbl1"L)

again, is it DirectCast for txt0.Text?

Thanks again for help.

Rich
 
C

Cor

Hi Rich,

Have first a look to the OleDBcommandbuilder, it builds the insert, the
update and the deletecommands for you.

Some of the more SQL regulars from the
"microsoft.public.dotnet.framework.adonet" newsgroup are always telling that
it can give errors with complex "select" statements and that you than have
to build those yourself or do it by using the Oledbadapter wizard and than
cut and paste the generated insert, update and delete code to another place.

But when you want to know more of it, ask it (or just look to it) also in
the newsgroup as I said above.

For this I would recomment to look at the comments of William (Bill) Vaughn

But have first a look at the commanbuilder,

I hope this helps,

Cor
 
R

Rich

Thank you again for your help. Actually, I did get these
commands going. Truth is, I am taking a class right now
in ADO.net and I am picking up VB.Net on the fly (have
read a book on vb.net). Since I also write some Java
code, I think I can handle the object orientedness of
vb.net (lots of real cool stuff in dotnet). Basically, I
am looking to migrate from the com environment (well, not
completely migrate but start using) to dotnet. I believe
that where I will really see the advantage of dotnet will
be in asp apps. Right now, good ole com ADO and VB6 serve
me quite well with Sql Server2K. But I have had some
issues with asp, so aspx it is, thus dotnet.

Going back to the topic, I have been using data components
from the toolbox for my project, so VB.net (the OS -
something) is generating the commands. I am just
manipulating them. Your trick with the array of textboxes
is really taking me places (that is a sweet feature of
dotnet, also like that you can create form properties
right in the form - too cool).

Well, I got over this obstacle, but I am confident that
more obstacles lie ahead. I thank you kindly for helping
me out.

Rich
 

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