473,804 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Call a TableAdapter Insert command

I think that this is a really simple question. I have a table adapter
set up with the various sql queries. I'd like to allow the user to
make changes to a given row on a form. Each of the changes is made
using textboxes (not a data grid). Once done, they click a Save
button, which should call the insert query on the tableadapter. I
can't seem to figure out how to call this. I could do it using a data
adapter, but there are many fields, so writing the query in code would
be very long and it's already there in the table adapter. Plus, if I
ever change the table schema, I can just change the insert command in
the TA and not have to update it my code.

Can anybody tell me what the code is to call this insert command?
e.g. myTA.Insert(myD S.myTable)

Thanks,
Randy

May 6 '07 #1
3 11227
Randy,

I think that you first have to ask yourself why you use a table as you
access all boxes seperatly. For the later you can use the
command.execute nonquery. For the dataadapter you could use databinding.

Cor

"Randy" <sp***********@ gmail.comschree f in bericht
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
>I think that this is a really simple question. I have a table adapter
set up with the various sql queries. I'd like to allow the user to
make changes to a given row on a form. Each of the changes is made
using textboxes (not a data grid). Once done, they click a Save
button, which should call the insert query on the tableadapter. I
can't seem to figure out how to call this. I could do it using a data
adapter, but there are many fields, so writing the query in code would
be very long and it's already there in the table adapter. Plus, if I
ever change the table schema, I can just change the insert command in
the TA and not have to update it my code.

Can anybody tell me what the code is to call this insert command?
e.g. myTA.Insert(myD S.myTable)

Thanks,
Randy

May 7 '07 #2
I have 37 text/combo boxes on my form, all relating to fields on a
single table. I'm using text and comboboxes rather than a data grid
simply so that I can organize the form in a user-friendly manner.
Right now, I've got 37 lines that start with
"cmdUpdate.Para meters.AddWithV alue" so that I can pass the values of
each of these boxes into my parameterized sql statement. Since I am
just using a single table, I was hoping that I can take advantage of
the table adapter on this table to avoid all of those parameter lines
before I get to the cmdUpdate.Execu teNonQuery call. It's just a lot
of lines to create and execute for something that is so conceptually
simple. Does that make sense?

Maybe databinding is a better answer. I'm still not very proficient
with this. I'll have to do some studying on that topic. That's a
good suggestion.

Thanks, Cor. I appreciate you thinking about this for me.

Randy

May 7 '07 #3
Randy,

You can make it yourself much easier by databinding.
You than have in pricipal only to load the tabel at the begin and update it
at the end.
(This is theoretical0

Have a look at this sample on our website)

http://www.vb-tips.com/dbpages.aspx?...9-4deb7fa4a0b8

http://www.vb-tips.com/dbpages.aspx?...8-2e91e5295e7c

To write you can for this kind of simple data use a commandbuilder

Cor
"Randy" <sp***********@ gmail.comschree f in bericht
news:11******** ************@n5 9g2000hsh.googl egroups.com...
>I have 37 text/combo boxes on my form, all relating to fields on a
single table. I'm using text and comboboxes rather than a data grid
simply so that I can organize the form in a user-friendly manner.
Right now, I've got 37 lines that start with
"cmdUpdate.Para meters.AddWithV alue" so that I can pass the values of
each of these boxes into my parameterized sql statement. Since I am
just using a single table, I was hoping that I can take advantage of
the table adapter on this table to avoid all of those parameter lines
before I get to the cmdUpdate.Execu teNonQuery call. It's just a lot
of lines to create and execute for something that is so conceptually
simple. Does that make sense?

Maybe databinding is a better answer. I'm still not very proficient
with this. I'll have to do some studying on that topic. That's a
good suggestion.

Thanks, Cor. I appreciate you thinking about this for me.

Randy

May 7 '07 #4

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

Similar topics

3
7227
by: Mike | last post by:
Dear Group, When I add a DataTable to a Typed Dataset, and a TableAdapter to the DataTable, I am able to create methods to send updates directly to the database (GenerateDBDirectMethods), however when my TableAdapter Fill SQL contains a WHERE clause which looks up a field from another joined table, the Fill works perfectly, but I cannot Insert, Update or Delete using the TableAdapter. Does anyone know why this is?
0
1846
by: vbnetguy | last post by:
Hopefully someone has an answer for this or maybe I am missing something. I have a stored procedure - this stored procedure is used as my main insert for a tableadapter I am doing something like mypolicyadapter.Update(mydatatable) after I add the appropriate rows... In this stored procedure I am executing multiple other stored
1
1798
by: hecsan07 | last post by:
Hey I am trying to get some practice on VS 2005 TableAdapter Configuration Wizard. I wrote a Database project and include a couple of stored procedures one of which was an insert procedure. The insert procedure obviously accepts a few parameters (the values to insert). I have a problem creating the connection in the TableAdapter Configuration Wizard for the insert procedure. Basically I cannot map the parameters to the database table...
3
9842
by: Ian Semmel | last post by:
The generated INSERT statement in a typed dataset has an INSERT statement followed by a SELECT statement which gets (I think) the value of the autoincremented ID. Question. How do I get hold of this value ?
0
1009
by: Elmo Watson | last post by:
Let's say I have a tableAdapter which uses an Insert sProc -- the last line in the sProc is a Select statement, returning the identity in code, I write something like: Dim myTA as (TableAdapter) label1.text=MyTA.Insert_sproc However, the label always gets 0, though the row is getting inserted - - anyone know how I can fix this?
1
13849
by: gmccallum | last post by:
I would have expected to be able to find this easily, but I couldn't. I am using the TableAdapter.Insert command to insert a record. I would like to then get an ID field from that record after insertion. How to I retreive the record just inserted? Gregory McCallum gmccallum@honovi.com
2
3985
by: needin4mation | last post by:
Hi, I have generated my queries and selected the refresh the table option. This creates a select after the insert to get the scope_identity() so that I can use that key value in another table, i.e. foreign keys. I have verified the existence of the select in the DAL .xsd file. I simply do not know how to get that value, the scope_identity() value. I know that it is selecting the value for me, but I have no idea how to get that selected...
0
1733
by: Yin99 | last post by:
I'm using TableAdapter with .NET 2.0 and SQL 2005. In SQL Database, a column's type is "float". Default TableAdapter methods update, insert, get, etc. maps this automatically to c# type "double" Question- Why is it when I create a new SQL Query, Insert Method, all of a sudden the tableadapter is calling the variable "float" when the default Insert method to tableadapter it is "double" ? What is
1
2195
by: Craig Buchanan | last post by:
I created a TableAdapter (TA) in my VB 2005 project. I tested it to ensure that its CRUD functionality is what I expected it to be. I'm using the TA and its strongly-typed DataTable (DT) in my Wizard. Initially, I populate the DT using the TA.GetData. I pass the DT to a ASCX-styled control that 'pivots' (turns years into columns) the data into a new DataTable (DT2), then binds it (DT2) to a GridView form. I save the original DT in...
0
9582
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
10580
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
10335
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...
0
9157
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
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
5525
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
4301
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
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
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.