Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-08
1
Medium Priority
?
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
jdavistx earned 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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!
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

670 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