473,770 Members | 5,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

run Insert/Delete DataAdapter commands?

Hello,

I have an oleDBDataAdapte r (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?

'''''''''''Inse rt routine
Dim txtCol As TextBox() = New Textbox(){txt0, txt1, txt2}
Dim txt As Textbox
For Each txt in txtCol
da1.InsertComma nd.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.DeleteComma nd.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 3258
Cor
Hi Rich,

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

Some of the more SQL regulars from the
"microsoft.publ ic.dotnet.frame work.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 oleDBDataAdapte r (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?

'''''''''''Inse rt routine
Dim txtCol As TextBox() = New Textbox(){txt0, txt1, txt2}
Dim txt As Textbox
For Each txt in txtCol
da1.InsertComma nd.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.DeleteComma nd.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 OleDBcommandbui lder, it builds the insert, theupdate and the deletecommands for you.

Some of the more SQL regulars from the
"microsoft.pub lic.dotnet.fram ework.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 oleDBDataAdapte r (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?

'''''''''''Inse rt routine
Dim txtCol As TextBox() = New Textbox(){txt0, txt1, txt2} Dim txt As Textbox
For Each txt in txtCol
da1.InsertComma nd.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.DeleteComma nd.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
17018
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 must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
6
2733
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 primary key violation and then handle it
5
7042
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
7279
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 screen are only a snapshot of the data stored in the datbase not the actual data itself. I just can't figure out what code I need in the click event of my corosponding command buttons to perform these actions. I presume I need to open, write and...
2
3711
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
1125
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 out the syntax. DataGrid1.Select(DataGrid1.CurrentRowIndex) OleDbDataAdapter1.DeleteCommand ???????????
4
4862
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 sql DataAdapter (da) da.SelectCommand.CommandText = "Select * from Servertbl1" da.Fill(ds, "tbl1") so far, so good. If I add a row to the datagridview I use the following sqlDataAdapter code to update the server table - which works OK when...
0
1952
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 another dataset I pull from the existing table (which is exactly the same except for an Identity Column as PK). When I call SqlDataAdapter.Update, no error is generated, but it makes no changes as well. I have one row present in the Database and...
13
8882
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 transaction. Does anyone have an SQL statement I can throw at it that would accomplish this? If I can't figure out how to do it, I'm going to have to send two discreet SQL commands for each record which will take infinitely longer than a...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10225
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6676
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.