473,394 Members | 1,715 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,394 software developers and data experts.

ADO.NET Beginner

I have a method called InsertUpdate which I want to use to handle both
insert's and update's. The GUI has a 2 textboxes: First Name and Last Name.
This is what my InsertUpdate method looks like right now.

InsertUpdate method:

SqlConnection cn = new SqlConnection("Initial Catalog=TEST;Data
Source=Server1;Integrated Security= SSPI");
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, FIRST_NAME, LAST_NAME
FROM TableName",cn);

SqlCommandBuilder thisBuilder = new SqlCommandBuilder(da);

DataSet ds = new DataSet();

da.Fill(ds,"TableName");
DataRow thisRow = ds.Tables["TableName"].NewRow();

thisRow["FIRST_NAME"] = txtFirstName.Text;

thisRow["LAST_NAME"] = txtLastName.Text;

ds.Tables["PLAYERS"].Rows.Add(thisRow);

da.Update(ds, "PLAYERS");

The next time I call the InsertUpdate method I want to update my data. How
do I do this with the code above? It obviously works for an insert but how
do I check if the data is dirty? so I can update my data. Any help would be
appreciated.

Richard

ri*************@yahoo.com

Nov 15 '05 #1
1 1455
How
do I do this with the code above? It obviously works for an insert but how do I check if the data is dirty? so I can update my data. Any help would be appreciated.


DataSet.HasChanges

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
Nov 15 '05 #2

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

Similar topics

8
by: Grrrbau | last post by:
I'm a beginner. I'm looking for a good C++ book. Someone told me about Lafore's "Object-Oriented Programming in C++". What do you think? Grrrbau
7
by: Rensjuh | last post by:
Hello, does someone have / know a good C++ tutorial for beginnners? I would prefer Dutch, but English is also fine. Hoi, heeft / kent iemand nog een goede C++ tutorial voor beginners? Het liefste...
27
by: MHoffman | last post by:
I am just learning to program, and hoping someone can help me with the following: for a simple calculator, a string is entered into a text box ... how do I prevent the user from entering a text...
18
by: mitchellpal | last post by:
Hi guys, am learning c as a beginner language and am finding it rough especially with pointers and data files. What do you think, am i being too pessimistic or thats how it happens for a beginner?...
22
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.