473,414 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

run Insert/Delete DataAdapter commands?

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


Nov 20 '05 #1
2 3239
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
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

Nov 20 '05 #2
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
-----Original Message-----
Hi Rich,

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

Some of the more SQL regulars from the
"microsoft.public.dotnet.framework.adonet" newsgroup are always telling thatit can give errors with complex "select" statements and that you than haveto build those yourself or do it by using the Oledbadapter wizard and thancut 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 inthe 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
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

.

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
6
by: Joey Lee | last post by:
Hi, I was wondering which is the best way of checking if a record exist in the database before inserting. There are quite a few ways I have seen. Here are some... 1> Insert and hit a...
5
by: SSP | last post by:
Dear ASP.NETers, How would I insert multiple rows of data from a web form? Are there any tute's and stuff around. Couldn't find any myself. Thanks in advance. SSP
7
by: Garry Newman | last post by:
From what I can gather these commands are automatically generated throught the OleDbDataAdapter wizard when working with a one table database and from the MSDN documnetation the values shown on...
2
by: John Smith | last post by:
i dont understand how to use `em all those @id ... what they have to do with a datagrid bound to a dataset filled by an adapter TIA
1
by: Tom McL. | last post by:
I have a datagrid bound to a database and I would like to be able to select a row programmable and then delete it. I have been trying to use the OleDbDataAdapter1.DeleteCommand but I can't figure...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
0
by: mcasey0827 | last post by:
I'm writing a little app to get data from a CSV file generated everyday by a vendor and insert it into a Table in our SQL Server database. I can get the data fine, and I can easily merge it with...
13
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.