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

Add new record using bound controls on windows form

I am writing an application in c# that connects to a SQL
server database. Following examples etc I can use bound
controls and with the position property go to a row and
edit it and save changes back to database. The problem is
I can't find how to set the position of the form to a new
row. If I just add a blank row to the datatable and then
try to go to it only works if all columns are nillable,
however this then leaves room for errors or I have to put
default values in columns that I don't want to have them.

Is there any way to point a bound form to a new row?

Thanks in advance
Paul
Jul 21 '05 #1
2 2343
Hi Paul,

What if you add a row with all columns having their default values

table.Rows.Add(new object[] {-1, "John", "Doe", "WA", "90876"});

And then set the CurrencyManager's position to the index of that row?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Paul Edwards" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I am writing an application in c# that connects to a SQL
server database. Following examples etc I can use bound
controls and with the position property go to a row and
edit it and save changes back to database. The problem is
I can't find how to set the position of the form to a new
row. If I just add a blank row to the datatable and then
try to go to it only works if all columns are nillable,
however this then leaves room for errors or I have to put
default values in columns that I don't want to have them.

Is there any way to point a bound form to a new row?

Thanks in advance
Paul


Jul 21 '05 #2
Dmitriy

Thanks for your suggestion but I have tried it and it
looks wrong to users to have a default name of John Doe on
the form, and combo boxes showing wrong values. Is there a
way to start it with blank values for all fields?

Paul
-----Original Message-----
Hi Paul,

What if you add a row with all columns having their default values
table.Rows.Add(new object[] {- 1, "John", "Doe", "WA", "90876"});
And then set the CurrencyManager's position to the index of that row?
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Paul Edwards" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
I am writing an application in c# that connects to a SQL
server database. Following examples etc I can use bound
controls and with the position property go to a row and
edit it and save changes back to database. The problem is I can't find how to set the position of the form to a new row. If I just add a blank row to the datatable and then
try to go to it only works if all columns are nillable,
however this then leaves room for errors or I have to put default values in columns that I don't want to have them.
Is there any way to point a bound form to a new row?

Thanks in advance
Paul


.

Jul 21 '05 #3

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

Similar topics

1
by: Maurice | last post by:
Hi In .NET I created a form with bound controls (Access Database). I used a dataset and followed examples to create a navigation using the Binding Context. So far everything goes well My...
5
by: HJ | last post by:
Hi all, Consider an Access 2002 run-time application on Windows XP. The controls on a form are locked until the user clicks an Edit button. The form is based on a query and all controls are...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
6
by: Steve | last post by:
I have a form, primary subform and secondary subform. A tab control takes up all the area of the primary subform. There are about 15 tabs on the tabcontrol. Each tab contains fields from the same...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
0
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
2
by: Paul Edwards | last post by:
I am writing an application in c# that connects to a SQL server database. Following examples etc I can use bound controls and with the position property go to a row and edit it and save changes...
6
by: kaosyeti | last post by:
hey.... i have a duplicate record issue i could use some help with. on a form that has 2 unbound controls, txtboxyear and cboxmonth, together will automatically fill in an invisible txtboxdate...
1
by: foothills bhc | last post by:
I have a problem with verifying content of controls on a form before closing the form or moving to the next form "record" (i.e., when moving to the next row of my form's record source). HERE'S THE...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.