471,120 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,120 software developers and data experts.

Re: DataSets and default columns

Steven

Thanks for your reply, however the typed datasets are defined in the web
service and there seems to way to open the partial class code window -
double clicking on the design surface does nothing. I can do this in the
client for a client specific dataset, but not in the web service.

--
Best regards
Mark Baldwin

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:qo**************@TK2MSFTNGHUB02.phx.gbl...
Hi Mark,

Based on your description, I understand that you have some Typed
DataSet/DataTables generated from database and will be transferred between
client and server through webservice. However, one of the table column is
set to AllowNull= false while you will need it be set to "true" when using
it at client or server code, correct?

As for the auto-generated typed-dataset, when you reconfigure it from
database, it does overwrite the original one therefore, if we manually
make
any changes on the dataset/table adapter, it will be changed after we
update it from database. Also, I can understand your concern that it's
better to keep data access code away from UI layer.

Currently I think we still need to write some custom code to set the
"AllowNull" property. However, to prevent the code from being overwrite
when update dataset or not coupled with UI layer, you may consider the
following approach:

**In .NET 2.0, auto-generated typed dataset/datatables use parital
classes.
Thus, you can also add another partial class file to extend the certain
typed DataSet or DataTable(and its TableAdapter).

#Extending Typed DataSets - Sorting Child Rows
http://www.madprops.org/cs/blogs/mab...ets-sorting-ch
ild-rows.aspx

You can add some custom method for the TableAdapter (which change the
AllowNull property of the certain DataTable or use your own SqlCommand
object for updating, inserting). You encapsulate all these code logic in a
single custom method.

e.g.

===============
public partial class personsDataTable {

private global::System.Data.DataColumn columnid;
private global::System.Data.DataColumn columnname;
...

public MyInit()
{
this.columnname.AllowDBNull = true;
}
..
=============
** In your actual code(in client or server application) which use this
TypedDataSet, you can simply call the custom function you defined above(at
the begining when you create an instance of that datatable). Though it
still require you to manually call the method, it reduce much data access
specific code.

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
From: "Mark Baldwin" <sW*****@community.nospam>
Subject: DataSets and default columns
Date: Wed, 9 Apr 2008 14:56:59 +0100

We have a 3 tiered application. Table <tblxresides in SQL2005, the
DataSet
<dsxis defined in the web service. The client creates instances of <dsx>
and passes them to the web service for storage/processing.

The table <tblxhas a column "EntryDate" with a default value of
"CURRENT_TIMESTAMP". When the DataSet <dsxis generated from the table,
the
EntryDate column is set to AllowNulls=false and the INSERT statement in
the
TableAdapter includes the EntryDate column.

Before I can use this DataSet I have to change AllowNulls to true,
otherwise
this column has to be filled in by the client before it can be sent the
DataSet to the WebService. I also have to change the TableAdapters INSERT
statement so as not to include the EntryDate column - since its
automatically populated by SQLServer.

This isn't too much of a problem, but everytime I modify the table
structure
I have to remember to do these two things after refreshing the DataSet and
to be honest it's becoming a bit long in the tooth.

Is there a way around these problems? I know I can set the EntryDate
column
in the table to AllowNulls but I don't want to do this, it's just not good
practise to allow UI problems to be solved in the data layer.

--
Best regards
Mark

Jun 27 '08 #1
1 1627
Thanks for your reply Mark,

Yes, when you use the "WebSite" project model for ASP.NET 2.0+ Web
application/webservice, it use a dynamic compilation mode. Thus, some
components such as Typed Dataset, webservice proxy will not show the
auto-generated code file. For such scenario, a common approach is move the
Typed Dataset into a class library project. Thus, you can add partial class
file for the typed dataset in the class library project. And in your
ASP.NET webservice project, you can reference the class library assembly to
use the typed Dataset. Do you think it workable for your scenario?

If there is any further questions, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Mark Baldwin" <sW*****@community.nospam>
References: <O2**************@TK2MSFTNGP06.phx.gbl>
<qo**************@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: DataSets and default columns
Date: Mon, 14 Apr 2008 11:38:38 +0100

Steven

Thanks for your reply, however the typed datasets are defined in the web
service and there seems to way to open the partial class code window -
double clicking on the design surface does nothing. I can do this in the
client for a client specific dataset, but not in the web service.

--
Best regards
Mark Baldwin

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:qo**************@TK2MSFTNGHUB02.phx.gbl...
Hi Mark,

Based on your description, I understand that you have some Typed
DataSet/DataTables generated from database and will be transferred between
client and server through webservice. However, one of the table column is
set to AllowNull= false while you will need it be set to "true" when using
it at client or server code, correct?

As for the auto-generated typed-dataset, when you reconfigure it from
database, it does overwrite the original one therefore, if we manually
make
any changes on the dataset/table adapter, it will be changed after we
update it from database. Also, I can understand your concern that it's
better to keep data access code away from UI layer.

Currently I think we still need to write some custom code to set the
"AllowNull" property. However, to prevent the code from being overwrite
when update dataset or not coupled with UI layer, you may consider the
following approach:

**In .NET 2.0, auto-generated typed dataset/datatables use parital
classes.
Thus, you can also add another partial class file to extend the certain
typed DataSet or DataTable(and its TableAdapter).

#Extending Typed DataSets - Sorting Child Rows
http://www.madprops.org/cs/blogs/mab...ets-sorting-ch
ild-rows.aspx

You can add some custom method for the TableAdapter (which change the
AllowNull property of the certain DataTable or use your own SqlCommand
object for updating, inserting). You encapsulate all these code logic in a
single custom method.

e.g.

===============
public partial class personsDataTable {

private global::System.Data.DataColumn columnid;
private global::System.Data.DataColumn columnname;
...

public MyInit()
{
this.columnname.AllowDBNull = true;
}
..
=============
** In your actual code(in client or server application) which use this
TypedDataSet, you can simply call the custom function you defined above(at
the begining when you create an instance of that datatable). Though it
still require you to manually call the method, it reduce much data access
specific code.

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
From: "Mark Baldwin" <sW*****@community.nospam>
Subject: DataSets and default columns
Date: Wed, 9 Apr 2008 14:56:59 +0100

We have a 3 tiered application. Table <tblxresides in SQL2005, the
DataSet
<dsxis defined in the web service. The client creates instances of <dsx>
and passes them to the web service for storage/processing.

The table <tblxhas a column "EntryDate" with a default value of
"CURRENT_TIMESTAMP". When the DataSet <dsxis generated from the table,
the
EntryDate column is set to AllowNulls=false and the INSERT statement in
the
TableAdapter includes the EntryDate column.

Before I can use this DataSet I have to change AllowNulls to true,
otherwise
this column has to be filled in by the client before it can be sent the
DataSet to the WebService. I also have to change the TableAdapters INSERT
statement so as not to include the EntryDate column - since its
automatically populated by SQLServer.

This isn't too much of a problem, but everytime I modify the table
structure
I have to remember to do these two things after refreshing the DataSet and
to be honest it's becoming a bit long in the tooth.

Is there a way around these problems? I know I can set the EntryDate
column
in the table to AllowNulls but I don't want to do this, it's just not good
practise to allow UI problems to be solved in the data layer.

--
Best regards
Mark


Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dan Cooper | last post: by
19 posts views Thread by Will Lastname | last post: by
1 post views Thread by tg.foobar | last post: by
4 posts views Thread by Frank | last post: by
7 posts views Thread by Ryan | last post: by

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.