Re: DataSets and default columns

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Baldwin

    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]" <stcheng@online .microsoft.comw rote in message
    news:qoj2djrmIH A.9932@TK2MSFTN GHUB02.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

    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 personsDataTabl e {
    >
    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:
    msdnmg@microsof t.com.
    >
    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    ications.
    >
    This posting is provided "AS IS" with no warranties, and confers no
    rights.
    >
    >
    >
    >
    >
    >
    --------------------
    From: "Mark Baldwin" <sWozzi3@commun ity.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_TIMEST AMP". When the DataSet <dsxis generated from the table,
    the
    EntryDate column is set to AllowNulls=fals e 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
    >
    >
    >

  • Steven Cheng [MSFT]

    #2
    Re: DataSets and default columns

    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:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    ications.

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


    --------------------
    From: "Mark Baldwin" <sWozzi3@commun ity.nospam>
    References: <O2dGOlkmIHA.37 80@TK2MSFTNGP06 .phx.gbl>
    <qoj2djrmIHA.99 32@TK2MSFTNGHUB 02.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]" <stcheng@online .microsoft.comw rote in message
    news:qoj2djrmIH A.9932@TK2MSFTN GHUB02.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 personsDataTabl e {
    >
    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:
    msdnmg@microsof t.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" <sWozzi3@commun ity.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_TIMEST AMP". When the DataSet <dsxis generated from the table,
    the
    EntryDate column is set to AllowNulls=fals e 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
    >
    >
    >


    Comment

    Working...