473,396 Members | 2,109 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,396 software developers and data experts.

Adding new record to Typed DataSet (using Enterprise Library)

Hi

I have a Typed DataSet.

I've databinded it to some text controls on my form, controls show data
when I show record.

But now I would like to create a new record with this form, controls and
dataset. A add new row to dataset:
<C#>
dokNaglowki1._DokNaglowki.AddDokNaglowkiRow(
dokNaglowki1._DokNaglowki.NewDokNaglowkiRow() );
</C#>

then alter data in controls and click save.

I save it like this:
<C#>
Database connection = DatabaseFactory.CreateDatabase();
//
// create adapter
//
using( DbDataAdapter adapter = connection.GetDataAdapter() )
{
//
// assign commnand to adapter
//
if( createText != null && createText.Length > 0 )
{
// dok_numer, dok_seria and dok_data are
// columns from DB and DS
// numer, seria, data are parameters of
// stored procedure used to add new records
// createText = DokNaglowkiDodaj - stored proc
adapter.InsertCommand =
connection.GetStoredProcCommand( createText );
connection.AddInParameter( adapter.InsertCommand,
"numer", DbType.Int32, "dok_numer", DataRowVersion.Current );
connection.AddInParameter( adapter.InsertCommand,
"seria", DbType.String, "dok_seria", DataRowVersion.Current );
connection.AddInParameter( adapter.InsertCommand,
"data", DbType.DateTime, "dok_data", DataRowVersion.Current );
adapter.InsertCommand.Connection =
connection.CreateConnection();
}
if( updateText != null && updateText.Length > 0 )
{
adapter.UpdateCommand =
connection.GetStoredProcCommand( updateText );
adapter.UpdateCommand.Connection =
connection.CreateConnection();
}
if( deleteText != null && deleteText.Length > 0 )
{
adapter.DeleteCommand =
connection.GetStoredProcCommand( deleteText );
adapter.DeleteCommand.Connection =
connection.CreateConnection();
}

//
// update target
//
return connection.UpdateDataSet( target, "DokNaglowki",
adapter.InsertCommand,
adapter.UpdateCommand, adapter.DeleteCommand,
UpdateBehavior.Standard );
</C#>

Everything looks ok. I've mostly copied it from Enterprise Library Demo.
But it won't work. Parameters' values are not set so I get Exception
from database because fields cannot have null value.

What am I doing wrong?

best regards
Mateusz [PEYN] Adamus
http://adamus.home.pl
Apr 7 '06 #1
0 4508

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

Similar topics

2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
2
by: David | last post by:
I have been developing applications with Java for quite a while but I am new to .NET development. I am trying to learn the ".NET way" of creating Strongly Typed Objects from a database. The...
2
by: Aaron Ackerman | last post by:
I cannot a row to this bound DataGrid to SAVE MY LIFE! I have tried everything and I am at a loss. The using goes into add mode with the add button adds his data then updates with the update...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
10
by: Trevor | last post by:
Hey, I am trying to do this tutorial on the microsoft site : http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dndotnet/html/usingadonet.asp I can get everything to work up to...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
5
by: John | last post by:
Hi, I am developing a windows app using C# 2005. This app uses SQL Server or Oracle database depending on the what the user is using. Can I create one typed dataset and use it for SQL Server and...
12
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
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
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,...

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.