Solved

Adding a new row to table in a windows forms application.

Posted on 2011-03-08
1
275 Views
Last Modified: 2012-05-11
I'm starting to use Visual Studio to create a Windows Forms application. I've just started.
I'm using C#. Visual Studio 2010.

I used Delphi since version 1, and I feel a bit lost... no, totally lost, regarding to all data access related in Visual Studio.

In Delphi, for adding a record I used to call MyTable.Insert(), which would clear the content of my TDBEdit's controls, the fill them with data and a button with a MyTable.Post(); to save the data.

Well, that's mean that only two lines of code are required to insert a new record in a table with Delphi.
In Visual Studio, I have no idea, but I'm guessing is not that simple.

So, the first thing I want to do, is to "emulate" this Delphi behavior.
I have my text controls already bound, and they show the first row in my table (in Sql),  I added a button with a "New" caption, which I want to clear the current row data to allow entry for new data.

How do I do that? :(




0
Comment
Question by:fischermx
1 Comment
 
LVL 7

Accepted Solution

by:
jdavistx earned 500 total points
ID: 35074649
There's a couple different ways you could achieve this, but you may want to take a look at the CurrencyManager

http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx

I assume you're wanting to append a new row, and not necessarily clear the current active row?

You could append a new blank row to your DataTable using:
myDataTable.Rows.Add(myDataTable.NewRow())

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question