Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default XSD VS.Net

    After configuring a relation data schema (MyDataSet.xsd) in vs.net, what
    code do you use to display that data within two dropdownlist controls (
    parent/child) in an web application?


    Leon Shaw Guest

  2. #2

    Default Re: XSD VS.Net

    Hi Leon,

    configuring a typed dataset only gets you halfway there (assuming that's
    what you are doing with the XSD). What you still need to do by hand is to
    write some ADO.NET code to establish the connection with the database and to
    actually load stuff in your dataset. For example, you could define a
    SqlDataAdapter, specify a SELECT... query and use .Fill with your typed
    DataSet as parameter (if you use SQL Server). It may be a little overkill to
    define a typed dataset and use a DataAdapter only to fill two dropdownlists.
    Take a look at the Data Access Application
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as easy as this
    (C#):

    DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
    CommandType.Text, "select name, value from mytable" );

    MyDropDownList.DataSource = MyDs.Tables[0];
    MyDropDownList.DataTextField = "name";
    MyDropDownList.DataValueField = "value";
    MyDropDownList.DataBind();

    Note that using a dataset always has some overhead, so you may want to use a
    SqlDataReader for performance.

    Best regards,

    Marc Hoeppner
    NeoGeo


    "Leon Shaw" <vnality@msn.com> wrote in message
    news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > After configuring a relation data schema (MyDataSet.xsd) in vs.net, what
    > code do you use to display that data within two dropdownlist controls (
    > parent/child) in an web application?
    >
    >

    Marc Hoeppner Guest

  3. #3

    Default Re: XSD VS.Net

    Ok I have call the adatper.fill and databind command, but is'nt some type of
    code such as Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    "DataSet1.xsd" I have to type to get the database schema from the .xsd file
    (I have two relate tables in my .xsd file "States" and "School". when you
    select a state from the first dropdownlist the second dropdownlist suppose
    to populate itself with the correct schools from that state. However, the
    first list populate with the states, (I have autopostback set to true, and
    the onchange event firing) but after the page postback the state
    dropdownlist displays System.Data.RelatedView over and over again. Thanks
    for the help!

    "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > Hi Leon,
    >
    > configuring a typed dataset only gets you halfway there (assuming that's
    > what you are doing with the XSD). What you still need to do by hand is to
    > write some ADO.NET code to establish the connection with the database and
    to
    > actually load stuff in your dataset. For example, you could define a
    > SqlDataAdapter, specify a SELECT... query and use .Fill with your typed
    > DataSet as parameter (if you use SQL Server). It may be a little overkill
    to
    > define a typed dataset and use a DataAdapter only to fill two
    dropdownlists.
    > Take a look at the Data Access Application
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as easy as this
    > (C#):
    >
    > DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
    > CommandType.Text, "select name, value from mytable" );
    >
    > MyDropDownList.DataSource = MyDs.Tables[0];
    > MyDropDownList.DataTextField = "name";
    > MyDropDownList.DataValueField = "value";
    > MyDropDownList.DataBind();
    >
    > Note that using a dataset always has some overhead, so you may want to use
    a
    > SqlDataReader for performance.
    >
    > Best regards,
    >
    > Marc Hoeppner
    > NeoGeo
    >
    >
    > "Leon Shaw" <vnality@msn.com> wrote in message
    > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > After configuring a relation data schema (MyDataSet.xsd) in vs.net, what
    > > code do you use to display that data within two dropdownlist controls (
    > > parent/child) in an web application?
    > >
    > >
    >
    >

    Leon Shaw Guest

  4. #4

    Default Re: XSD VS.Net

    Well, basically you can have VS.NET do the grunt work for you. If you
    right-click on your project file, select add, then add class, select dataset
    and use any name you like (dataset1.xsd) is fine. Now use the server
    explorer to drag a few tables in the XSD and use the toolbox to add
    references and/or new fields as needed. Now, when you do this and compile
    your project, VS.NET will use a tool (XGEN.EXE) to generate a C# file for
    you that implements a strongly typed dataset. You can use it like any other
    dataset but it is also a strongly typed class with all the parameters that
    your tables have. You can also manually change the XSD file or use the GUI
    to build your XSD from scratch.

    But if all you want to do is to fill two DropDownLists I would recommend to
    use the Data Access Application Blocks or simple ADO.NET to get a DataTable
    for each table separately and attach these to the dropdownlists.

    One other thing: you can help the databind process to find the right columns
    to display by the user of DataTextField and DataValueField. For example, if
    you have a DataTable with 4 columns (Company, Street, Country, CompanyID)
    and you want the ddl to display the Company as text and have the CompanyID
    as the value you'd do something like this:

    MyDropDownList.DataSource = MyDataTable;
    MyDropDownList.DataTextField = "Company";
    MyDropDownList.DataValueField = "CompanyID";
    MyDropDownList.DataBind();

    Hope this helps!!

    Best regards,

    Marc Höppner
    NeoGeo

    "Leon Shaw" <vnality@msn.com> wrote in message
    news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > Ok I have call the adatper.fill and databind command, but is'nt some type
    of
    > code such as Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > "DataSet1.xsd" I have to type to get the database schema from the .xsd
    file
    > (I have two relate tables in my .xsd file "States" and "School". when you
    > select a state from the first dropdownlist the second dropdownlist suppose
    > to populate itself with the correct schools from that state. However, the
    > first list populate with the states, (I have autopostback set to true, and
    > the onchange event firing) but after the page postback the state
    > dropdownlist displays System.Data.RelatedView over and over again. Thanks
    > for the help!
    >
    > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > Hi Leon,
    > >
    > > configuring a typed dataset only gets you halfway there (assuming that's
    > > what you are doing with the XSD). What you still need to do by hand is
    to
    > > write some ADO.NET code to establish the connection with the database
    and
    > to
    > > actually load stuff in your dataset. For example, you could define a
    > > SqlDataAdapter, specify a SELECT... query and use .Fill with your typed
    > > DataSet as parameter (if you use SQL Server). It may be a little
    overkill
    > to
    > > define a typed dataset and use a DataAdapter only to fill two
    > dropdownlists.
    > > Take a look at the Data Access Application
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as easy as
    this
    > > (C#):
    > >
    > > DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
    > > CommandType.Text, "select name, value from mytable" );
    > >
    > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > MyDropDownList.DataTextField = "name";
    > > MyDropDownList.DataValueField = "value";
    > > MyDropDownList.DataBind();
    > >
    > > Note that using a dataset always has some overhead, so you may want to
    use
    > a
    > > SqlDataReader for performance.
    > >
    > > Best regards,
    > >
    > > Marc Hoeppner
    > > NeoGeo
    > >
    > >
    > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > After configuring a relation data schema (MyDataSet.xsd) in vs.net,
    what
    > > > code do you use to display that data within two dropdownlist controls
    (
    > > > parent/child) in an web application?
    > > >
    > > >
    > >
    > >
    >
    >

    Marc Hoeppner Guest

  5. #5

    Default Re: XSD VS.Net

    do you have remote desktop. I would like you to see want I'm doing for
    yourself. I have did everything you stated, and have reference multiple
    books and is yet to solve the problem. I thinking of setting up a parameter
    stored procedure to get the state id to binding the right schools for that
    state in the dropdownlist. The reason I chose the .xsd relational dataset
    route, it easy to define relationships among tables. What do you think?

    "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > Well, basically you can have VS.NET do the grunt work for you. If you
    > right-click on your project file, select add, then add class, select
    dataset
    > and use any name you like (dataset1.xsd) is fine. Now use the server
    > explorer to drag a few tables in the XSD and use the toolbox to add
    > references and/or new fields as needed. Now, when you do this and compile
    > your project, VS.NET will use a tool (XGEN.EXE) to generate a C# file for
    > you that implements a strongly typed dataset. You can use it like any
    other
    > dataset but it is also a strongly typed class with all the parameters that
    > your tables have. You can also manually change the XSD file or use the GUI
    > to build your XSD from scratch.
    >
    > But if all you want to do is to fill two DropDownLists I would recommend
    to
    > use the Data Access Application Blocks or simple ADO.NET to get a
    DataTable
    > for each table separately and attach these to the dropdownlists.
    >
    > One other thing: you can help the databind process to find the right
    columns
    > to display by the user of DataTextField and DataValueField. For example,
    if
    > you have a DataTable with 4 columns (Company, Street, Country, CompanyID)
    > and you want the ddl to display the Company as text and have the CompanyID
    > as the value you'd do something like this:
    >
    > MyDropDownList.DataSource = MyDataTable;
    > MyDropDownList.DataTextField = "Company";
    > MyDropDownList.DataValueField = "CompanyID";
    > MyDropDownList.DataBind();
    >
    > Hope this helps!!
    >
    > Best regards,
    >
    > Marc Höppner
    > NeoGeo
    >
    > "Leon Shaw" <vnality@msn.com> wrote in message
    > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > Ok I have call the adatper.fill and databind command, but is'nt some
    type
    > of
    > > code such as Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > "DataSet1.xsd" I have to type to get the database schema from the .xsd
    > file
    > > (I have two relate tables in my .xsd file "States" and "School". when
    you
    > > select a state from the first dropdownlist the second dropdownlist
    suppose
    > > to populate itself with the correct schools from that state. However,
    the
    > > first list populate with the states, (I have autopostback set to true,
    and
    > > the onchange event firing) but after the page postback the state
    > > dropdownlist displays System.Data.RelatedView over and over again.
    Thanks
    > > for the help!
    > >
    > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > Hi Leon,
    > > >
    > > > configuring a typed dataset only gets you halfway there (assuming
    that's
    > > > what you are doing with the XSD). What you still need to do by hand is
    > to
    > > > write some ADO.NET code to establish the connection with the database
    > and
    > > to
    > > > actually load stuff in your dataset. For example, you could define a
    > > > SqlDataAdapter, specify a SELECT... query and use .Fill with your
    typed
    > > > DataSet as parameter (if you use SQL Server). It may be a little
    > overkill
    > > to
    > > > define a typed dataset and use a DataAdapter only to fill two
    > > dropdownlists.
    > > > Take a look at the Data Access Application
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as easy as
    > this
    > > > (C#):
    > > >
    > > > DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
    > > > CommandType.Text, "select name, value from mytable" );
    > > >
    > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > MyDropDownList.DataTextField = "name";
    > > > MyDropDownList.DataValueField = "value";
    > > > MyDropDownList.DataBind();
    > > >
    > > > Note that using a dataset always has some overhead, so you may want to
    > use
    > > a
    > > > SqlDataReader for performance.
    > > >
    > > > Best regards,
    > > >
    > > > Marc Hoeppner
    > > > NeoGeo
    > > >
    > > >
    > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > After configuring a relation data schema (MyDataSet.xsd) in vs.net,
    > what
    > > > > code do you use to display that data within two dropdownlist
    controls
    > (
    > > > > parent/child) in an web application?
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Leon Shaw Guest

  6. #6

    Default Re: XSD VS.Net

    I am not sure I get what you want to do. Could you elaborate a little?

    webform2.aspx is not good going practice at all as I load all customers and
    all orders into the typed dataset. I think webform1.aspx is a much, much
    better implementation (faster, easier to read, easier to change, faster...).

    "Leon Shaw" <vnality@msn.com> wrote in message
    news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > how do do that same code but reference the name of the relationship such
    as
    > (CustomersOrders) in the DataSet1.xsd file to populate the dropdownlist.
    >
    > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > With regards to your application, I still think there is an easier way
    to
    > do
    > > that. I am sure you know that by now, but just to be safe: You need be
    > aware
    > > that typed datasets don't write the code for you to access and retrieve
    > > data. You still need to do all the loading/saving etc. yourself in code.
    > > Also, the databinding process for web controls does not automatically
    take
    > > care of connected tables inside a dataset (typed or not), you also have
    to
    > > do this yourself.
    > >
    > > The straight-forward approach to solving your problem (using the
    Northwind
    > > database) is attached to this post on page webform1.aspx. You need to
    edit
    > > the connection string and the sample is done using SQL Server or MSDE.
    The
    > > typed dataset version is on page webform2.aspx.
    > >
    > > And yes, I have remote desktop, so we can set up a time if you want to
    and
    > > I'll give it a quick look.
    > >
    > >
    > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > do you have remote desktop. I would like you to see want I'm doing for
    > > > yourself. I have did everything you stated, and have reference
    multiple
    > > > books and is yet to solve the problem. I thinking of setting up a
    > > parameter
    > > > stored procedure to get the state id to binding the right schools for
    > that
    > > > state in the dropdownlist. The reason I chose the .xsd relational
    > dataset
    > > > route, it easy to define relationships among tables. What do you
    think?
    > > >
    > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > Well, basically you can have VS.NET do the grunt work for you. If
    you
    > > > > right-click on your project file, select add, then add class, select
    > > > dataset
    > > > > and use any name you like (dataset1.xsd) is fine. Now use the server
    > > > > explorer to drag a few tables in the XSD and use the toolbox to add
    > > > > references and/or new fields as needed. Now, when you do this and
    > > compile
    > > > > your project, VS.NET will use a tool (XGEN.EXE) to generate a C#
    file
    > > for
    > > > > you that implements a strongly typed dataset. You can use it like
    any
    > > > other
    > > > > dataset but it is also a strongly typed class with all the
    parameters
    > > that
    > > > > your tables have. You can also manually change the XSD file or use
    the
    > > GUI
    > > > > to build your XSD from scratch.
    > > > >
    > > > > But if all you want to do is to fill two DropDownLists I would
    > recommend
    > > > to
    > > > > use the Data Access Application Blocks or simple ADO.NET to get a
    > > > DataTable
    > > > > for each table separately and attach these to the dropdownlists.
    > > > >
    > > > > One other thing: you can help the databind process to find the right
    > > > columns
    > > > > to display by the user of DataTextField and DataValueField. For
    > example,
    > > > if
    > > > > you have a DataTable with 4 columns (Company, Street, Country,
    > > CompanyID)
    > > > > and you want the ddl to display the Company as text and have the
    > > CompanyID
    > > > > as the value you'd do something like this:
    > > > >
    > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > MyDropDownList.DataTextField = "Company";
    > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > MyDropDownList.DataBind();
    > > > >
    > > > > Hope this helps!!
    > > > >
    > > > > Best regards,
    > > > >
    > > > > Marc Höppner
    > > > > NeoGeo
    > > > >
    > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > Ok I have call the adatper.fill and databind command, but is'nt
    some
    > > > type
    > > > > of
    > > > > > code such as Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > "DataSet1.xsd" I have to type to get the database schema from the
    > .xsd
    > > > > file
    > > > > > (I have two relate tables in my .xsd file "States" and "School".
    > when
    > > > you
    > > > > > select a state from the first dropdownlist the second dropdownlist
    > > > suppose
    > > > > > to populate itself with the correct schools from that state.
    > However,
    > > > the
    > > > > > first list populate with the states, (I have autopostback set to
    > true,
    > > > and
    > > > > > the onchange event firing) but after the page postback the state
    > > > > > dropdownlist displays System.Data.RelatedView over and over again.
    > > > Thanks
    > > > > > for the help!
    > > > > >
    > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > Hi Leon,
    > > > > > >
    > > > > > > configuring a typed dataset only gets you halfway there
    (assuming
    > > > that's
    > > > > > > what you are doing with the XSD). What you still need to do by
    > hand
    > > is
    > > > > to
    > > > > > > write some ADO.NET code to establish the connection with the
    > > database
    > > > > and
    > > > > > to
    > > > > > > actually load stuff in your dataset. For example, you could
    define
    > a
    > > > > > > SqlDataAdapter, specify a SELECT... query and use .Fill with
    your
    > > > typed
    > > > > > > DataSet as parameter (if you use SQL Server). It may be a little
    > > > > overkill
    > > > > > to
    > > > > > > define a typed dataset and use a DataAdapter only to fill two
    > > > > > dropdownlists.
    > > > > > > Take a look at the Data Access Application
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as
    easy
    > as
    > > > > this
    > > > > > > (C#):
    > > > > > >
    > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
    > > > > > > CommandType.Text, "select name, value from mytable" );
    > > > > > >
    > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > MyDropDownList.DataBind();
    > > > > > >
    > > > > > > Note that using a dataset always has some overhead, so you may
    > want
    > > to
    > > > > use
    > > > > > a
    > > > > > > SqlDataReader for performance.
    > > > > > >
    > > > > > > Best regards,
    > > > > > >
    > > > > > > Marc Hoeppner
    > > > > > > NeoGeo
    > > > > > >
    > > > > > >
    > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > After configuring a relation data schema (MyDataSet.xsd) in
    > > vs.net,
    > > > > what
    > > > > > > > code do you use to display that data within two dropdownlist
    > > > controls
    > > > > (
    > > > > > > > parent/child) in an web application?
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    > >
    >
    >

    Marc Hoeppner Guest

  7. #7

    Default Re: XSD VS.Net

    So I should set up a store procedure in my MS SQL 2000 database for cities
    (@StateID) and get the StateDropDownList.DataValueField and pass that value
    (@StateID) to display the correct Schools in the SchoolDropDownlist?
    Correct!


    "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    news:uJ6XvKvSDHA.2852@tk2msftngp13.phx.gbl...
    > I am not sure I get what you want to do. Could you elaborate a little?
    >
    > webform2.aspx is not good going practice at all as I load all customers
    and
    > all orders into the typed dataset. I think webform1.aspx is a much, much
    > better implementation (faster, easier to read, easier to change,
    faster...).
    >
    > "Leon Shaw" <vnality@msn.com> wrote in message
    > news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > how do do that same code but reference the name of the relationship such
    > as
    > > (CustomersOrders) in the DataSet1.xsd file to populate the dropdownlist.
    > >
    > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > With regards to your application, I still think there is an easier way
    > to
    > > do
    > > > that. I am sure you know that by now, but just to be safe: You need be
    > > aware
    > > > that typed datasets don't write the code for you to access and
    retrieve
    > > > data. You still need to do all the loading/saving etc. yourself in
    code.
    > > > Also, the databinding process for web controls does not automatically
    > take
    > > > care of connected tables inside a dataset (typed or not), you also
    have
    > to
    > > > do this yourself.
    > > >
    > > > The straight-forward approach to solving your problem (using the
    > Northwind
    > > > database) is attached to this post on page webform1.aspx. You need to
    > edit
    > > > the connection string and the sample is done using SQL Server or MSDE.
    > The
    > > > typed dataset version is on page webform2.aspx.
    > > >
    > > > And yes, I have remote desktop, so we can set up a time if you want to
    > and
    > > > I'll give it a quick look.
    > > >
    > > >
    > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > > do you have remote desktop. I would like you to see want I'm doing
    for
    > > > > yourself. I have did everything you stated, and have reference
    > multiple
    > > > > books and is yet to solve the problem. I thinking of setting up a
    > > > parameter
    > > > > stored procedure to get the state id to binding the right schools
    for
    > > that
    > > > > state in the dropdownlist. The reason I chose the .xsd relational
    > > dataset
    > > > > route, it easy to define relationships among tables. What do you
    > think?
    > > > >
    > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > > Well, basically you can have VS.NET do the grunt work for you. If
    > you
    > > > > > right-click on your project file, select add, then add class,
    select
    > > > > dataset
    > > > > > and use any name you like (dataset1.xsd) is fine. Now use the
    server
    > > > > > explorer to drag a few tables in the XSD and use the toolbox to
    add
    > > > > > references and/or new fields as needed. Now, when you do this and
    > > > compile
    > > > > > your project, VS.NET will use a tool (XGEN.EXE) to generate a C#
    > file
    > > > for
    > > > > > you that implements a strongly typed dataset. You can use it like
    > any
    > > > > other
    > > > > > dataset but it is also a strongly typed class with all the
    > parameters
    > > > that
    > > > > > your tables have. You can also manually change the XSD file or use
    > the
    > > > GUI
    > > > > > to build your XSD from scratch.
    > > > > >
    > > > > > But if all you want to do is to fill two DropDownLists I would
    > > recommend
    > > > > to
    > > > > > use the Data Access Application Blocks or simple ADO.NET to get a
    > > > > DataTable
    > > > > > for each table separately and attach these to the dropdownlists.
    > > > > >
    > > > > > One other thing: you can help the databind process to find the
    right
    > > > > columns
    > > > > > to display by the user of DataTextField and DataValueField. For
    > > example,
    > > > > if
    > > > > > you have a DataTable with 4 columns (Company, Street, Country,
    > > > CompanyID)
    > > > > > and you want the ddl to display the Company as text and have the
    > > > CompanyID
    > > > > > as the value you'd do something like this:
    > > > > >
    > > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > > MyDropDownList.DataTextField = "Company";
    > > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > > MyDropDownList.DataBind();
    > > > > >
    > > > > > Hope this helps!!
    > > > > >
    > > > > > Best regards,
    > > > > >
    > > > > > Marc Höppner
    > > > > > NeoGeo
    > > > > >
    > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > > Ok I have call the adatper.fill and databind command, but is'nt
    > some
    > > > > type
    > > > > > of
    > > > > > > code such as
    Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > > "DataSet1.xsd" I have to type to get the database schema from
    the
    > > .xsd
    > > > > > file
    > > > > > > (I have two relate tables in my .xsd file "States" and "School".
    > > when
    > > > > you
    > > > > > > select a state from the first dropdownlist the second
    dropdownlist
    > > > > suppose
    > > > > > > to populate itself with the correct schools from that state.
    > > However,
    > > > > the
    > > > > > > first list populate with the states, (I have autopostback set to
    > > true,
    > > > > and
    > > > > > > the onchange event firing) but after the page postback the state
    > > > > > > dropdownlist displays System.Data.RelatedView over and over
    again.
    > > > > Thanks
    > > > > > > for the help!
    > > > > > >
    > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > > Hi Leon,
    > > > > > > >
    > > > > > > > configuring a typed dataset only gets you halfway there
    > (assuming
    > > > > that's
    > > > > > > > what you are doing with the XSD). What you still need to do by
    > > hand
    > > > is
    > > > > > to
    > > > > > > > write some ADO.NET code to establish the connection with the
    > > > database
    > > > > > and
    > > > > > > to
    > > > > > > > actually load stuff in your dataset. For example, you could
    > define
    > > a
    > > > > > > > SqlDataAdapter, specify a SELECT... query and use .Fill with
    > your
    > > > > typed
    > > > > > > > DataSet as parameter (if you use SQL Server). It may be a
    little
    > > > > > overkill
    > > > > > > to
    > > > > > > > define a typed dataset and use a DataAdapter only to fill two
    > > > > > > dropdownlists.
    > > > > > > > Take a look at the Data Access Application
    > > > > > > >
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as
    > easy
    > > as
    > > > > > this
    > > > > > > > (C#):
    > > > > > > >
    > > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
    > > > > > > > CommandType.Text, "select name, value from mytable" );
    > > > > > > >
    > > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > > MyDropDownList.DataBind();
    > > > > > > >
    > > > > > > > Note that using a dataset always has some overhead, so you may
    > > want
    > > > to
    > > > > > use
    > > > > > > a
    > > > > > > > SqlDataReader for performance.
    > > > > > > >
    > > > > > > > Best regards,
    > > > > > > >
    > > > > > > > Marc Hoeppner
    > > > > > > > NeoGeo
    > > > > > > >
    > > > > > > >
    > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > > After configuring a relation data schema (MyDataSet.xsd) in
    > > > vs.net,
    > > > > > what
    > > > > > > > > code do you use to display that data within two dropdownlist
    > > > > controls
    > > > > > (
    > > > > > > > > parent/child) in an web application?
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Leon Shaw Guest

  8. #8

    Default Re: XSD VS.Net

    Yes, you can do that!

    "Leon Shaw" <vnality@msn.com> wrote in message
    news:%23WQEPcvSDHA.632@tk2msftngp13.phx.gbl...
    > So I should set up a store procedure in my MS SQL 2000 database for cities
    > (@StateID) and get the StateDropDownList.DataValueField and pass that
    value
    > (@StateID) to display the correct Schools in the SchoolDropDownlist?
    > Correct!
    >
    >
    > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > news:uJ6XvKvSDHA.2852@tk2msftngp13.phx.gbl...
    > > I am not sure I get what you want to do. Could you elaborate a little?
    > >
    > > webform2.aspx is not good going practice at all as I load all customers
    > and
    > > all orders into the typed dataset. I think webform1.aspx is a much, much
    > > better implementation (faster, easier to read, easier to change,
    > faster...).
    > >
    > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > > how do do that same code but reference the name of the relationship
    such
    > > as
    > > > (CustomersOrders) in the DataSet1.xsd file to populate the
    dropdownlist.
    > > >
    > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > With regards to your application, I still think there is an easier
    way
    > > to
    > > > do
    > > > > that. I am sure you know that by now, but just to be safe: You need
    be
    > > > aware
    > > > > that typed datasets don't write the code for you to access and
    > retrieve
    > > > > data. You still need to do all the loading/saving etc. yourself in
    > code.
    > > > > Also, the databinding process for web controls does not
    automatically
    > > take
    > > > > care of connected tables inside a dataset (typed or not), you also
    > have
    > > to
    > > > > do this yourself.
    > > > >
    > > > > The straight-forward approach to solving your problem (using the
    > > Northwind
    > > > > database) is attached to this post on page webform1.aspx. You need
    to
    > > edit
    > > > > the connection string and the sample is done using SQL Server or
    MSDE.
    > > The
    > > > > typed dataset version is on page webform2.aspx.
    > > > >
    > > > > And yes, I have remote desktop, so we can set up a time if you want
    to
    > > and
    > > > > I'll give it a quick look.
    > > > >
    > > > >
    > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > > > do you have remote desktop. I would like you to see want I'm doing
    > for
    > > > > > yourself. I have did everything you stated, and have reference
    > > multiple
    > > > > > books and is yet to solve the problem. I thinking of setting up a
    > > > > parameter
    > > > > > stored procedure to get the state id to binding the right schools
    > for
    > > > that
    > > > > > state in the dropdownlist. The reason I chose the .xsd relational
    > > > dataset
    > > > > > route, it easy to define relationships among tables. What do you
    > > think?
    > > > > >
    > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > > > Well, basically you can have VS.NET do the grunt work for you.
    If
    > > you
    > > > > > > right-click on your project file, select add, then add class,
    > select
    > > > > > dataset
    > > > > > > and use any name you like (dataset1.xsd) is fine. Now use the
    > server
    > > > > > > explorer to drag a few tables in the XSD and use the toolbox to
    > add
    > > > > > > references and/or new fields as needed. Now, when you do this
    and
    > > > > compile
    > > > > > > your project, VS.NET will use a tool (XGEN.EXE) to generate a C#
    > > file
    > > > > for
    > > > > > > you that implements a strongly typed dataset. You can use it
    like
    > > any
    > > > > > other
    > > > > > > dataset but it is also a strongly typed class with all the
    > > parameters
    > > > > that
    > > > > > > your tables have. You can also manually change the XSD file or
    use
    > > the
    > > > > GUI
    > > > > > > to build your XSD from scratch.
    > > > > > >
    > > > > > > But if all you want to do is to fill two DropDownLists I would
    > > > recommend
    > > > > > to
    > > > > > > use the Data Access Application Blocks or simple ADO.NET to get
    a
    > > > > > DataTable
    > > > > > > for each table separately and attach these to the dropdownlists.
    > > > > > >
    > > > > > > One other thing: you can help the databind process to find the
    > right
    > > > > > columns
    > > > > > > to display by the user of DataTextField and DataValueField. For
    > > > example,
    > > > > > if
    > > > > > > you have a DataTable with 4 columns (Company, Street, Country,
    > > > > CompanyID)
    > > > > > > and you want the ddl to display the Company as text and have the
    > > > > CompanyID
    > > > > > > as the value you'd do something like this:
    > > > > > >
    > > > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > > > MyDropDownList.DataTextField = "Company";
    > > > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > > > MyDropDownList.DataBind();
    > > > > > >
    > > > > > > Hope this helps!!
    > > > > > >
    > > > > > > Best regards,
    > > > > > >
    > > > > > > Marc Höppner
    > > > > > > NeoGeo
    > > > > > >
    > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > > > Ok I have call the adatper.fill and databind command, but
    is'nt
    > > some
    > > > > > type
    > > > > > > of
    > > > > > > > code such as
    > Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > > > "DataSet1.xsd" I have to type to get the database schema from
    > the
    > > > .xsd
    > > > > > > file
    > > > > > > > (I have two relate tables in my .xsd file "States" and
    "School".
    > > > when
    > > > > > you
    > > > > > > > select a state from the first dropdownlist the second
    > dropdownlist
    > > > > > suppose
    > > > > > > > to populate itself with the correct schools from that state.
    > > > However,
    > > > > > the
    > > > > > > > first list populate with the states, (I have autopostback set
    to
    > > > true,
    > > > > > and
    > > > > > > > the onchange event firing) but after the page postback the
    state
    > > > > > > > dropdownlist displays System.Data.RelatedView over and over
    > again.
    > > > > > Thanks
    > > > > > > > for the help!
    > > > > > > >
    > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > Hi Leon,
    > > > > > > > >
    > > > > > > > > configuring a typed dataset only gets you halfway there
    > > (assuming
    > > > > > that's
    > > > > > > > > what you are doing with the XSD). What you still need to do
    by
    > > > hand
    > > > > is
    > > > > > > to
    > > > > > > > > write some ADO.NET code to establish the connection with the
    > > > > database
    > > > > > > and
    > > > > > > > to
    > > > > > > > > actually load stuff in your dataset. For example, you could
    > > define
    > > > a
    > > > > > > > > SqlDataAdapter, specify a SELECT... query and use .Fill with
    > > your
    > > > > > typed
    > > > > > > > > DataSet as parameter (if you use SQL Server). It may be a
    > little
    > > > > > > overkill
    > > > > > > > to
    > > > > > > > > define a typed dataset and use a DataAdapter only to fill
    two
    > > > > > > > dropdownlists.
    > > > > > > > > Take a look at the Data Access Application
    > > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be as
    > > easy
    > > > as
    > > > > > > this
    > > > > > > > > (C#):
    > > > > > > > >
    > > > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet( MyConnectionString,
    > > > > > > > > CommandType.Text, "select name, value from mytable" );
    > > > > > > > >
    > > > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > >
    > > > > > > > > Note that using a dataset always has some overhead, so you
    may
    > > > want
    > > > > to
    > > > > > > use
    > > > > > > > a
    > > > > > > > > SqlDataReader for performance.
    > > > > > > > >
    > > > > > > > > Best regards,
    > > > > > > > >
    > > > > > > > > Marc Hoeppner
    > > > > > > > > NeoGeo
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > > > After configuring a relation data schema (MyDataSet.xsd)
    in
    > > > > vs.net,
    > > > > > > what
    > > > > > > > > > code do you use to display that data within two
    dropdownlist
    > > > > > controls
    > > > > > > (
    > > > > > > > > > parent/child) in an web application?
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Marc Hoeppner Guest

  9. #9

    Default Re: XSD VS.Net

    is that a better way, and more efficient way of doing it? However, Thanks
    for all the help!
    "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    news:%23QHDd8vSDHA.3132@tk2msftngp13.phx.gbl...
    > Yes, you can do that!
    >
    > "Leon Shaw" <vnality@msn.com> wrote in message
    > news:%23WQEPcvSDHA.632@tk2msftngp13.phx.gbl...
    > > So I should set up a store procedure in my MS SQL 2000 database for
    cities
    > > (@StateID) and get the StateDropDownList.DataValueField and pass that
    > value
    > > (@StateID) to display the correct Schools in the SchoolDropDownlist?
    > > Correct!
    > >
    > >
    > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > news:uJ6XvKvSDHA.2852@tk2msftngp13.phx.gbl...
    > > > I am not sure I get what you want to do. Could you elaborate a little?
    > > >
    > > > webform2.aspx is not good going practice at all as I load all
    customers
    > > and
    > > > all orders into the typed dataset. I think webform1.aspx is a much,
    much
    > > > better implementation (faster, easier to read, easier to change,
    > > faster...).
    > > >
    > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > > > how do do that same code but reference the name of the relationship
    > such
    > > > as
    > > > > (CustomersOrders) in the DataSet1.xsd file to populate the
    > dropdownlist.
    > > > >
    > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > > With regards to your application, I still think there is an easier
    > way
    > > > to
    > > > > do
    > > > > > that. I am sure you know that by now, but just to be safe: You
    need
    > be
    > > > > aware
    > > > > > that typed datasets don't write the code for you to access and
    > > retrieve
    > > > > > data. You still need to do all the loading/saving etc. yourself in
    > > code.
    > > > > > Also, the databinding process for web controls does not
    > automatically
    > > > take
    > > > > > care of connected tables inside a dataset (typed or not), you also
    > > have
    > > > to
    > > > > > do this yourself.
    > > > > >
    > > > > > The straight-forward approach to solving your problem (using the
    > > > Northwind
    > > > > > database) is attached to this post on page webform1.aspx. You need
    > to
    > > > edit
    > > > > > the connection string and the sample is done using SQL Server or
    > MSDE.
    > > > The
    > > > > > typed dataset version is on page webform2.aspx.
    > > > > >
    > > > > > And yes, I have remote desktop, so we can set up a time if you
    want
    > to
    > > > and
    > > > > > I'll give it a quick look.
    > > > > >
    > > > > >
    > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > > > > do you have remote desktop. I would like you to see want I'm
    doing
    > > for
    > > > > > > yourself. I have did everything you stated, and have reference
    > > > multiple
    > > > > > > books and is yet to solve the problem. I thinking of setting up
    a
    > > > > > parameter
    > > > > > > stored procedure to get the state id to binding the right
    schools
    > > for
    > > > > that
    > > > > > > state in the dropdownlist. The reason I chose the .xsd
    relational
    > > > > dataset
    > > > > > > route, it easy to define relationships among tables. What do you
    > > > think?
    > > > > > >
    > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > > > > Well, basically you can have VS.NET do the grunt work for you.
    > If
    > > > you
    > > > > > > > right-click on your project file, select add, then add class,
    > > select
    > > > > > > dataset
    > > > > > > > and use any name you like (dataset1.xsd) is fine. Now use the
    > > server
    > > > > > > > explorer to drag a few tables in the XSD and use the toolbox
    to
    > > add
    > > > > > > > references and/or new fields as needed. Now, when you do this
    > and
    > > > > > compile
    > > > > > > > your project, VS.NET will use a tool (XGEN.EXE) to generate a
    C#
    > > > file
    > > > > > for
    > > > > > > > you that implements a strongly typed dataset. You can use it
    > like
    > > > any
    > > > > > > other
    > > > > > > > dataset but it is also a strongly typed class with all the
    > > > parameters
    > > > > > that
    > > > > > > > your tables have. You can also manually change the XSD file or
    > use
    > > > the
    > > > > > GUI
    > > > > > > > to build your XSD from scratch.
    > > > > > > >
    > > > > > > > But if all you want to do is to fill two DropDownLists I would
    > > > > recommend
    > > > > > > to
    > > > > > > > use the Data Access Application Blocks or simple ADO.NET to
    get
    > a
    > > > > > > DataTable
    > > > > > > > for each table separately and attach these to the
    dropdownlists.
    > > > > > > >
    > > > > > > > One other thing: you can help the databind process to find the
    > > right
    > > > > > > columns
    > > > > > > > to display by the user of DataTextField and DataValueField.
    For
    > > > > example,
    > > > > > > if
    > > > > > > > you have a DataTable with 4 columns (Company, Street, Country,
    > > > > > CompanyID)
    > > > > > > > and you want the ddl to display the Company as text and have
    the
    > > > > > CompanyID
    > > > > > > > as the value you'd do something like this:
    > > > > > > >
    > > > > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > > > > MyDropDownList.DataTextField = "Company";
    > > > > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > > > > MyDropDownList.DataBind();
    > > > > > > >
    > > > > > > > Hope this helps!!
    > > > > > > >
    > > > > > > > Best regards,
    > > > > > > >
    > > > > > > > Marc Höppner
    > > > > > > > NeoGeo
    > > > > > > >
    > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > Ok I have call the adatper.fill and databind command, but
    > is'nt
    > > > some
    > > > > > > type
    > > > > > > > of
    > > > > > > > > code such as
    > > Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > > > > "DataSet1.xsd" I have to type to get the database schema
    from
    > > the
    > > > > .xsd
    > > > > > > > file
    > > > > > > > > (I have two relate tables in my .xsd file "States" and
    > "School".
    > > > > when
    > > > > > > you
    > > > > > > > > select a state from the first dropdownlist the second
    > > dropdownlist
    > > > > > > suppose
    > > > > > > > > to populate itself with the correct schools from that state.
    > > > > However,
    > > > > > > the
    > > > > > > > > first list populate with the states, (I have autopostback
    set
    > to
    > > > > true,
    > > > > > > and
    > > > > > > > > the onchange event firing) but after the page postback the
    > state
    > > > > > > > > dropdownlist displays System.Data.RelatedView over and over
    > > again.
    > > > > > > Thanks
    > > > > > > > > for the help!
    > > > > > > > >
    > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > Hi Leon,
    > > > > > > > > >
    > > > > > > > > > configuring a typed dataset only gets you halfway there
    > > > (assuming
    > > > > > > that's
    > > > > > > > > > what you are doing with the XSD). What you still need to
    do
    > by
    > > > > hand
    > > > > > is
    > > > > > > > to
    > > > > > > > > > write some ADO.NET code to establish the connection with
    the
    > > > > > database
    > > > > > > > and
    > > > > > > > > to
    > > > > > > > > > actually load stuff in your dataset. For example, you
    could
    > > > define
    > > > > a
    > > > > > > > > > SqlDataAdapter, specify a SELECT... query and use .Fill
    with
    > > > your
    > > > > > > typed
    > > > > > > > > > DataSet as parameter (if you use SQL Server). It may be a
    > > little
    > > > > > > > overkill
    > > > > > > > > to
    > > > > > > > > > define a typed dataset and use a DataAdapter only to fill
    > two
    > > > > > > > > dropdownlists.
    > > > > > > > > > Take a look at the Data Access Application
    > > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could be
    as
    > > > easy
    > > > > as
    > > > > > > > this
    > > > > > > > > > (C#):
    > > > > > > > > >
    > > > > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet(
    MyConnectionString,
    > > > > > > > > > CommandType.Text, "select name, value from mytable" );
    > > > > > > > > >
    > > > > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > >
    > > > > > > > > > Note that using a dataset always has some overhead, so you
    > may
    > > > > want
    > > > > > to
    > > > > > > > use
    > > > > > > > > a
    > > > > > > > > > SqlDataReader for performance.
    > > > > > > > > >
    > > > > > > > > > Best regards,
    > > > > > > > > >
    > > > > > > > > > Marc Hoeppner
    > > > > > > > > > NeoGeo
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > > > > After configuring a relation data schema (MyDataSet.xsd)
    > in
    > > > > > vs.net,
    > > > > > > > what
    > > > > > > > > > > code do you use to display that data within two
    > dropdownlist
    > > > > > > controls
    > > > > > > > (
    > > > > > > > > > > parent/child) in an web application?
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Leon Shaw Guest

  10. #10

    Default Re: XSD VS.Net

    I GOT IT TO WORK. THANKS SO MUCH, but so What you are saying is that I don't
    even have to use a dataset at all. All I really need to do is use
    sqlcommands to pull data into my form for easy selection Then use a dataset
    to pull all the information from every form field and update the database?
    Correct
    "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    news:OcZIe3wSDHA.2128@TK2MSFTNGP12.phx.gbl...
    > The method used in webform1.aspx should be a lot better than using typed
    > datasets in this case. Depending on your scenario you could some caching
    or
    > even load all the orders (in this case) in a dataset if all customers get
    > selected pretty frequently.
    >
    > If you still shoot for the typed dataset, you can start with the
    > webform2.aspx sample and go from there. You can change the sample to use
    > SPROCs instead of inline SQL, but you still will have to do the filtering
    of
    > the dataset either in T-SQL or by use of the Select or Filter functions in
    > DataSet/DataTable manually.
    > :)
    >
    > "Leon Shaw" <vnality@msn.com> wrote in message
    > news:OzY2jKwSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > is that a better way, and more efficient way of doing it? However,
    Thanks
    > > for all the help!
    > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > news:%23QHDd8vSDHA.3132@tk2msftngp13.phx.gbl...
    > > > Yes, you can do that!
    > > >
    > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > news:%23WQEPcvSDHA.632@tk2msftngp13.phx.gbl...
    > > > > So I should set up a store procedure in my MS SQL 2000 database for
    > > cities
    > > > > (@StateID) and get the StateDropDownList.DataValueField and pass
    that
    > > > value
    > > > > (@StateID) to display the correct Schools in the SchoolDropDownlist?
    > > > > Correct!
    > > > >
    > > > >
    > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > news:uJ6XvKvSDHA.2852@tk2msftngp13.phx.gbl...
    > > > > > I am not sure I get what you want to do. Could you elaborate a
    > little?
    > > > > >
    > > > > > webform2.aspx is not good going practice at all as I load all
    > > customers
    > > > > and
    > > > > > all orders into the typed dataset. I think webform1.aspx is a
    much,
    > > much
    > > > > > better implementation (faster, easier to read, easier to change,
    > > > > faster...).
    > > > > >
    > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > > > > > how do do that same code but reference the name of the
    > relationship
    > > > such
    > > > > > as
    > > > > > > (CustomersOrders) in the DataSet1.xsd file to populate the
    > > > dropdownlist.
    > > > > > >
    > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > > > > With regards to your application, I still think there is an
    > easier
    > > > way
    > > > > > to
    > > > > > > do
    > > > > > > > that. I am sure you know that by now, but just to be safe: You
    > > need
    > > > be
    > > > > > > aware
    > > > > > > > that typed datasets don't write the code for you to access and
    > > > > retrieve
    > > > > > > > data. You still need to do all the loading/saving etc.
    yourself
    > in
    > > > > code.
    > > > > > > > Also, the databinding process for web controls does not
    > > > automatically
    > > > > > take
    > > > > > > > care of connected tables inside a dataset (typed or not), you
    > also
    > > > > have
    > > > > > to
    > > > > > > > do this yourself.
    > > > > > > >
    > > > > > > > The straight-forward approach to solving your problem (using
    the
    > > > > > Northwind
    > > > > > > > database) is attached to this post on page webform1.aspx. You
    > need
    > > > to
    > > > > > edit
    > > > > > > > the connection string and the sample is done using SQL Server
    or
    > > > MSDE.
    > > > > > The
    > > > > > > > typed dataset version is on page webform2.aspx.
    > > > > > > >
    > > > > > > > And yes, I have remote desktop, so we can set up a time if you
    > > want
    > > > to
    > > > > > and
    > > > > > > > I'll give it a quick look.
    > > > > > > >
    > > > > > > >
    > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > do you have remote desktop. I would like you to see want I'm
    > > doing
    > > > > for
    > > > > > > > > yourself. I have did everything you stated, and have
    reference
    > > > > > multiple
    > > > > > > > > books and is yet to solve the problem. I thinking of setting
    > up
    > > a
    > > > > > > > parameter
    > > > > > > > > stored procedure to get the state id to binding the right
    > > schools
    > > > > for
    > > > > > > that
    > > > > > > > > state in the dropdownlist. The reason I chose the .xsd
    > > relational
    > > > > > > dataset
    > > > > > > > > route, it easy to define relationships among tables. What do
    > you
    > > > > > think?
    > > > > > > > >
    > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > Well, basically you can have VS.NET do the grunt work for
    > you.
    > > > If
    > > > > > you
    > > > > > > > > > right-click on your project file, select add, then add
    > class,
    > > > > select
    > > > > > > > > dataset
    > > > > > > > > > and use any name you like (dataset1.xsd) is fine. Now use
    > the
    > > > > server
    > > > > > > > > > explorer to drag a few tables in the XSD and use the
    toolbox
    > > to
    > > > > add
    > > > > > > > > > references and/or new fields as needed. Now, when you do
    > this
    > > > and
    > > > > > > > compile
    > > > > > > > > > your project, VS.NET will use a tool (XGEN.EXE) to
    generate
    > a
    > > C#
    > > > > > file
    > > > > > > > for
    > > > > > > > > > you that implements a strongly typed dataset. You can use
    it
    > > > like
    > > > > > any
    > > > > > > > > other
    > > > > > > > > > dataset but it is also a strongly typed class with all the
    > > > > > parameters
    > > > > > > > that
    > > > > > > > > > your tables have. You can also manually change the XSD
    file
    > or
    > > > use
    > > > > > the
    > > > > > > > GUI
    > > > > > > > > > to build your XSD from scratch.
    > > > > > > > > >
    > > > > > > > > > But if all you want to do is to fill two DropDownLists I
    > would
    > > > > > > recommend
    > > > > > > > > to
    > > > > > > > > > use the Data Access Application Blocks or simple ADO.NET
    to
    > > get
    > > > a
    > > > > > > > > DataTable
    > > > > > > > > > for each table separately and attach these to the
    > > dropdownlists.
    > > > > > > > > >
    > > > > > > > > > One other thing: you can help the databind process to find
    > the
    > > > > right
    > > > > > > > > columns
    > > > > > > > > > to display by the user of DataTextField and
    DataValueField.
    > > For
    > > > > > > example,
    > > > > > > > > if
    > > > > > > > > > you have a DataTable with 4 columns (Company, Street,
    > Country,
    > > > > > > > CompanyID)
    > > > > > > > > > and you want the ddl to display the Company as text and
    have
    > > the
    > > > > > > > CompanyID
    > > > > > > > > > as the value you'd do something like this:
    > > > > > > > > >
    > > > > > > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > > > > > > MyDropDownList.DataTextField = "Company";
    > > > > > > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > >
    > > > > > > > > > Hope this helps!!
    > > > > > > > > >
    > > > > > > > > > Best regards,
    > > > > > > > > >
    > > > > > > > > > Marc Höppner
    > > > > > > > > > NeoGeo
    > > > > > > > > >
    > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > > > Ok I have call the adatper.fill and databind command,
    but
    > > > is'nt
    > > > > > some
    > > > > > > > > type
    > > > > > > > > > of
    > > > > > > > > > > code such as
    > > > > Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > > > > > > "DataSet1.xsd" I have to type to get the database schema
    > > from
    > > > > the
    > > > > > > .xsd
    > > > > > > > > > file
    > > > > > > > > > > (I have two relate tables in my .xsd file "States" and
    > > > "School".
    > > > > > > when
    > > > > > > > > you
    > > > > > > > > > > select a state from the first dropdownlist the second
    > > > > dropdownlist
    > > > > > > > > suppose
    > > > > > > > > > > to populate itself with the correct schools from that
    > state.
    > > > > > > However,
    > > > > > > > > the
    > > > > > > > > > > first list populate with the states, (I have
    autopostback
    > > set
    > > > to
    > > > > > > true,
    > > > > > > > > and
    > > > > > > > > > > the onchange event firing) but after the page postback
    the
    > > > state
    > > > > > > > > > > dropdownlist displays System.Data.RelatedView over and
    > over
    > > > > again.
    > > > > > > > > Thanks
    > > > > > > > > > > for the help!
    > > > > > > > > > >
    > > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in
    > message
    > > > > > > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > > Hi Leon,
    > > > > > > > > > > >
    > > > > > > > > > > > configuring a typed dataset only gets you halfway
    there
    > > > > > (assuming
    > > > > > > > > that's
    > > > > > > > > > > > what you are doing with the XSD). What you still need
    to
    > > do
    > > > by
    > > > > > > hand
    > > > > > > > is
    > > > > > > > > > to
    > > > > > > > > > > > write some ADO.NET code to establish the connection
    with
    > > the
    > > > > > > > database
    > > > > > > > > > and
    > > > > > > > > > > to
    > > > > > > > > > > > actually load stuff in your dataset. For example, you
    > > could
    > > > > > define
    > > > > > > a
    > > > > > > > > > > > SqlDataAdapter, specify a SELECT... query and use
    ..Fill
    > > with
    > > > > > your
    > > > > > > > > typed
    > > > > > > > > > > > DataSet as parameter (if you use SQL Server). It may
    be
    > a
    > > > > little
    > > > > > > > > > overkill
    > > > > > > > > > > to
    > > > > > > > > > > > define a typed dataset and use a DataAdapter only to
    > fill
    > > > two
    > > > > > > > > > > dropdownlists.
    > > > > > > > > > > > Take a look at the Data Access Application
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it could
    > be
    > > as
    > > > > > easy
    > > > > > > as
    > > > > > > > > > this
    > > > > > > > > > > > (C#):
    > > > > > > > > > > >
    > > > > > > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet(
    > > MyConnectionString,
    > > > > > > > > > > > CommandType.Text, "select name, value from mytable" );
    > > > > > > > > > > >
    > > > > > > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > > > >
    > > > > > > > > > > > Note that using a dataset always has some overhead, so
    > you
    > > > may
    > > > > > > want
    > > > > > > > to
    > > > > > > > > > use
    > > > > > > > > > > a
    > > > > > > > > > > > SqlDataReader for performance.
    > > > > > > > > > > >
    > > > > > > > > > > > Best regards,
    > > > > > > > > > > >
    > > > > > > > > > > > Marc Hoeppner
    > > > > > > > > > > > NeoGeo
    > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > > > > > > After configuring a relation data schema
    > (MyDataSet.xsd)
    > > > in
    > > > > > > > vs.net,
    > > > > > > > > > what
    > > > > > > > > > > > > code do you use to display that data within two
    > > > dropdownlist
    > > > > > > > > controls
    > > > > > > > > > (
    > > > > > > > > > > > > parent/child) in an web application?
    > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Leon Shaw Guest

  11. #11

    Default Re: XSD VS.Net

    Great, congrats!!

    A dataset is very powerfull on the one hand, but on the other has a lot of
    overhead. So you need to use it appropriately. Yes, you don't need a dataset
    to fill a dropdownlist, but you also have to count other factors such as
    ease of use and amount of code to type. So, I'd use something similar to the
    webform1.aspx approach and make sure that the page caching is set to a long
    time period if your data does not changes very often. This way you have the
    ease of use as in the first sample, but the database code only gets called a
    few times a time for example. So, this was selecting data.
    Inserting/updating data can be done by a dataset as well, but if you only
    update a few items in a form you can as well use an SPROC and send it the
    values from your form directly without a dataset. If you have a larger
    application and use data over and over again on different pages, it may be a
    good idea to build a couple of typed datasets where appropriate and use them
    both for selecting and for inserting/updating.

    "Leon Shaw" <vnality@msn.com> wrote in message
    news:egfNRBxSDHA.2460@TK2MSFTNGP10.phx.gbl...
    > I GOT IT TO WORK. THANKS SO MUCH, but so What you are saying is that I
    don't
    > even have to use a dataset at all. All I really need to do is use
    > sqlcommands to pull data into my form for easy selection Then use a
    dataset
    > to pull all the information from every form field and update the database?
    > Correct
    > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > news:OcZIe3wSDHA.2128@TK2MSFTNGP12.phx.gbl...
    > > The method used in webform1.aspx should be a lot better than using typed
    > > datasets in this case. Depending on your scenario you could some caching
    > or
    > > even load all the orders (in this case) in a dataset if all customers
    get
    > > selected pretty frequently.
    > >
    > > If you still shoot for the typed dataset, you can start with the
    > > webform2.aspx sample and go from there. You can change the sample to use
    > > SPROCs instead of inline SQL, but you still will have to do the
    filtering
    > of
    > > the dataset either in T-SQL or by use of the Select or Filter functions
    in
    > > DataSet/DataTable manually.
    > > :)
    > >
    > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > news:OzY2jKwSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > is that a better way, and more efficient way of doing it? However,
    > Thanks
    > > > for all the help!
    > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > news:%23QHDd8vSDHA.3132@tk2msftngp13.phx.gbl...
    > > > > Yes, you can do that!
    > > > >
    > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > news:%23WQEPcvSDHA.632@tk2msftngp13.phx.gbl...
    > > > > > So I should set up a store procedure in my MS SQL 2000 database
    for
    > > > cities
    > > > > > (@StateID) and get the StateDropDownList.DataValueField and pass
    > that
    > > > > value
    > > > > > (@StateID) to display the correct Schools in the
    SchoolDropDownlist?
    > > > > > Correct!
    > > > > >
    > > > > >
    > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > news:uJ6XvKvSDHA.2852@tk2msftngp13.phx.gbl...
    > > > > > > I am not sure I get what you want to do. Could you elaborate a
    > > little?
    > > > > > >
    > > > > > > webform2.aspx is not good going practice at all as I load all
    > > > customers
    > > > > > and
    > > > > > > all orders into the typed dataset. I think webform1.aspx is a
    > much,
    > > > much
    > > > > > > better implementation (faster, easier to read, easier to change,
    > > > > > faster...).
    > > > > > >
    > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > > > > > > how do do that same code but reference the name of the
    > > relationship
    > > > > such
    > > > > > > as
    > > > > > > > (CustomersOrders) in the DataSet1.xsd file to populate the
    > > > > dropdownlist.
    > > > > > > >
    > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > With regards to your application, I still think there is an
    > > easier
    > > > > way
    > > > > > > to
    > > > > > > > do
    > > > > > > > > that. I am sure you know that by now, but just to be safe:
    You
    > > > need
    > > > > be
    > > > > > > > aware
    > > > > > > > > that typed datasets don't write the code for you to access
    and
    > > > > > retrieve
    > > > > > > > > data. You still need to do all the loading/saving etc.
    > yourself
    > > in
    > > > > > code.
    > > > > > > > > Also, the databinding process for web controls does not
    > > > > automatically
    > > > > > > take
    > > > > > > > > care of connected tables inside a dataset (typed or not),
    you
    > > also
    > > > > > have
    > > > > > > to
    > > > > > > > > do this yourself.
    > > > > > > > >
    > > > > > > > > The straight-forward approach to solving your problem (using
    > the
    > > > > > > Northwind
    > > > > > > > > database) is attached to this post on page webform1.aspx.
    You
    > > need
    > > > > to
    > > > > > > edit
    > > > > > > > > the connection string and the sample is done using SQL
    Server
    > or
    > > > > MSDE.
    > > > > > > The
    > > > > > > > > typed dataset version is on page webform2.aspx.
    > > > > > > > >
    > > > > > > > > And yes, I have remote desktop, so we can set up a time if
    you
    > > > want
    > > > > to
    > > > > > > and
    > > > > > > > > I'll give it a quick look.
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > > do you have remote desktop. I would like you to see want
    I'm
    > > > doing
    > > > > > for
    > > > > > > > > > yourself. I have did everything you stated, and have
    > reference
    > > > > > > multiple
    > > > > > > > > > books and is yet to solve the problem. I thinking of
    setting
    > > up
    > > > a
    > > > > > > > > parameter
    > > > > > > > > > stored procedure to get the state id to binding the right
    > > > schools
    > > > > > for
    > > > > > > > that
    > > > > > > > > > state in the dropdownlist. The reason I chose the .xsd
    > > > relational
    > > > > > > > dataset
    > > > > > > > > > route, it easy to define relationships among tables. What
    do
    > > you
    > > > > > > think?
    > > > > > > > > >
    > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in
    message
    > > > > > > > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > Well, basically you can have VS.NET do the grunt work
    for
    > > you.
    > > > > If
    > > > > > > you
    > > > > > > > > > > right-click on your project file, select add, then add
    > > class,
    > > > > > select
    > > > > > > > > > dataset
    > > > > > > > > > > and use any name you like (dataset1.xsd) is fine. Now
    use
    > > the
    > > > > > server
    > > > > > > > > > > explorer to drag a few tables in the XSD and use the
    > toolbox
    > > > to
    > > > > > add
    > > > > > > > > > > references and/or new fields as needed. Now, when you do
    > > this
    > > > > and
    > > > > > > > > compile
    > > > > > > > > > > your project, VS.NET will use a tool (XGEN.EXE) to
    > generate
    > > a
    > > > C#
    > > > > > > file
    > > > > > > > > for
    > > > > > > > > > > you that implements a strongly typed dataset. You can
    use
    > it
    > > > > like
    > > > > > > any
    > > > > > > > > > other
    > > > > > > > > > > dataset but it is also a strongly typed class with all
    the
    > > > > > > parameters
    > > > > > > > > that
    > > > > > > > > > > your tables have. You can also manually change the XSD
    > file
    > > or
    > > > > use
    > > > > > > the
    > > > > > > > > GUI
    > > > > > > > > > > to build your XSD from scratch.
    > > > > > > > > > >
    > > > > > > > > > > But if all you want to do is to fill two DropDownLists I
    > > would
    > > > > > > > recommend
    > > > > > > > > > to
    > > > > > > > > > > use the Data Access Application Blocks or simple ADO.NET
    > to
    > > > get
    > > > > a
    > > > > > > > > > DataTable
    > > > > > > > > > > for each table separately and attach these to the
    > > > dropdownlists.
    > > > > > > > > > >
    > > > > > > > > > > One other thing: you can help the databind process to
    find
    > > the
    > > > > > right
    > > > > > > > > > columns
    > > > > > > > > > > to display by the user of DataTextField and
    > DataValueField.
    > > > For
    > > > > > > > example,
    > > > > > > > > > if
    > > > > > > > > > > you have a DataTable with 4 columns (Company, Street,
    > > Country,
    > > > > > > > > CompanyID)
    > > > > > > > > > > and you want the ddl to display the Company as text and
    > have
    > > > the
    > > > > > > > > CompanyID
    > > > > > > > > > > as the value you'd do something like this:
    > > > > > > > > > >
    > > > > > > > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > > > > > > > MyDropDownList.DataTextField = "Company";
    > > > > > > > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > > >
    > > > > > > > > > > Hope this helps!!
    > > > > > > > > > >
    > > > > > > > > > > Best regards,
    > > > > > > > > > >
    > > > > > > > > > > Marc Höppner
    > > > > > > > > > > NeoGeo
    > > > > > > > > > >
    > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > > > > Ok I have call the adatper.fill and databind command,
    > but
    > > > > is'nt
    > > > > > > some
    > > > > > > > > > type
    > > > > > > > > > > of
    > > > > > > > > > > > code such as
    > > > > > Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > > > > > > > "DataSet1.xsd" I have to type to get the database
    schema
    > > > from
    > > > > > the
    > > > > > > > .xsd
    > > > > > > > > > > file
    > > > > > > > > > > > (I have two relate tables in my .xsd file "States" and
    > > > > "School".
    > > > > > > > when
    > > > > > > > > > you
    > > > > > > > > > > > select a state from the first dropdownlist the second
    > > > > > dropdownlist
    > > > > > > > > > suppose
    > > > > > > > > > > > to populate itself with the correct schools from that
    > > state.
    > > > > > > > However,
    > > > > > > > > > the
    > > > > > > > > > > > first list populate with the states, (I have
    > autopostback
    > > > set
    > > > > to
    > > > > > > > true,
    > > > > > > > > > and
    > > > > > > > > > > > the onchange event firing) but after the page postback
    > the
    > > > > state
    > > > > > > > > > > > dropdownlist displays System.Data.RelatedView over and
    > > over
    > > > > > again.
    > > > > > > > > > Thanks
    > > > > > > > > > > > for the help!
    > > > > > > > > > > >
    > > > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in
    > > message
    > > > > > > > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > > > Hi Leon,
    > > > > > > > > > > > >
    > > > > > > > > > > > > configuring a typed dataset only gets you halfway
    > there
    > > > > > > (assuming
    > > > > > > > > > that's
    > > > > > > > > > > > > what you are doing with the XSD). What you still
    need
    > to
    > > > do
    > > > > by
    > > > > > > > hand
    > > > > > > > > is
    > > > > > > > > > > to
    > > > > > > > > > > > > write some ADO.NET code to establish the connection
    > with
    > > > the
    > > > > > > > > database
    > > > > > > > > > > and
    > > > > > > > > > > > to
    > > > > > > > > > > > > actually load stuff in your dataset. For example,
    you
    > > > could
    > > > > > > define
    > > > > > > > a
    > > > > > > > > > > > > SqlDataAdapter, specify a SELECT... query and use
    > .Fill
    > > > with
    > > > > > > your
    > > > > > > > > > typed
    > > > > > > > > > > > > DataSet as parameter (if you use SQL Server). It may
    > be
    > > a
    > > > > > little
    > > > > > > > > > > overkill
    > > > > > > > > > > > to
    > > > > > > > > > > > > define a typed dataset and use a DataAdapter only to
    > > fill
    > > > > two
    > > > > > > > > > > > dropdownlists.
    > > > > > > > > > > > > Take a look at the Data Access Application
    > > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it
    could
    > > be
    > > > as
    > > > > > > easy
    > > > > > > > as
    > > > > > > > > > > this
    > > > > > > > > > > > > (C#):
    > > > > > > > > > > > >
    > > > > > > > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet(
    > > > MyConnectionString,
    > > > > > > > > > > > > CommandType.Text, "select name, value from
    mytable" );
    > > > > > > > > > > > >
    > > > > > > > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > > > > >
    > > > > > > > > > > > > Note that using a dataset always has some overhead,
    so
    > > you
    > > > > may
    > > > > > > > want
    > > > > > > > > to
    > > > > > > > > > > use
    > > > > > > > > > > > a
    > > > > > > > > > > > > SqlDataReader for performance.
    > > > > > > > > > > > >
    > > > > > > > > > > > > Best regards,
    > > > > > > > > > > > >
    > > > > > > > > > > > > Marc Hoeppner
    > > > > > > > > > > > > NeoGeo
    > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > > > > > > > After configuring a relation data schema
    > > (MyDataSet.xsd)
    > > > > in
    > > > > > > > > vs.net,
    > > > > > > > > > > what
    > > > > > > > > > > > > > code do you use to display that data within two
    > > > > dropdownlist
    > > > > > > > > > controls
    > > > > > > > > > > (
    > > > > > > > > > > > > > parent/child) in an web application?
    > > > > > > > > > > > > >
    > > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Marc Hoeppner Guest

  12. #12

    Default Re: XSD VS.Net

    Thanks So Much! I will surely apply and share the knowledge.
    "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    news:OwIWglxSDHA.2256@TK2MSFTNGP11.phx.gbl...
    > Great, congrats!!
    >
    > A dataset is very powerfull on the one hand, but on the other has a lot of
    > overhead. So you need to use it appropriately. Yes, you don't need a
    dataset
    > to fill a dropdownlist, but you also have to count other factors such as
    > ease of use and amount of code to type. So, I'd use something similar to
    the
    > webform1.aspx approach and make sure that the page caching is set to a
    long
    > time period if your data does not changes very often. This way you have
    the
    > ease of use as in the first sample, but the database code only gets called
    a
    > few times a time for example. So, this was selecting data.
    > Inserting/updating data can be done by a dataset as well, but if you only
    > update a few items in a form you can as well use an SPROC and send it the
    > values from your form directly without a dataset. If you have a larger
    > application and use data over and over again on different pages, it may be
    a
    > good idea to build a couple of typed datasets where appropriate and use
    them
    > both for selecting and for inserting/updating.
    >
    > "Leon Shaw" <vnality@msn.com> wrote in message
    > news:egfNRBxSDHA.2460@TK2MSFTNGP10.phx.gbl...
    > > I GOT IT TO WORK. THANKS SO MUCH, but so What you are saying is that I
    > don't
    > > even have to use a dataset at all. All I really need to do is use
    > > sqlcommands to pull data into my form for easy selection Then use a
    > dataset
    > > to pull all the information from every form field and update the
    database?
    > > Correct
    > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > news:OcZIe3wSDHA.2128@TK2MSFTNGP12.phx.gbl...
    > > > The method used in webform1.aspx should be a lot better than using
    typed
    > > > datasets in this case. Depending on your scenario you could some
    caching
    > > or
    > > > even load all the orders (in this case) in a dataset if all customers
    > get
    > > > selected pretty frequently.
    > > >
    > > > If you still shoot for the typed dataset, you can start with the
    > > > webform2.aspx sample and go from there. You can change the sample to
    use
    > > > SPROCs instead of inline SQL, but you still will have to do the
    > filtering
    > > of
    > > > the dataset either in T-SQL or by use of the Select or Filter
    functions
    > in
    > > > DataSet/DataTable manually.
    > > > :)
    > > >
    > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > news:OzY2jKwSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > is that a better way, and more efficient way of doing it? However,
    > > Thanks
    > > > > for all the help!
    > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > news:%23QHDd8vSDHA.3132@tk2msftngp13.phx.gbl...
    > > > > > Yes, you can do that!
    > > > > >
    > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > news:%23WQEPcvSDHA.632@tk2msftngp13.phx.gbl...
    > > > > > > So I should set up a store procedure in my MS SQL 2000 database
    > for
    > > > > cities
    > > > > > > (@StateID) and get the StateDropDownList.DataValueField and pass
    > > that
    > > > > > value
    > > > > > > (@StateID) to display the correct Schools in the
    > SchoolDropDownlist?
    > > > > > > Correct!
    > > > > > >
    > > > > > >
    > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > news:uJ6XvKvSDHA.2852@tk2msftngp13.phx.gbl...
    > > > > > > > I am not sure I get what you want to do. Could you elaborate a
    > > > little?
    > > > > > > >
    > > > > > > > webform2.aspx is not good going practice at all as I load all
    > > > > customers
    > > > > > > and
    > > > > > > > all orders into the typed dataset. I think webform1.aspx is a
    > > much,
    > > > > much
    > > > > > > > better implementation (faster, easier to read, easier to
    change,
    > > > > > > faster...).
    > > > > > > >
    > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > how do do that same code but reference the name of the
    > > > relationship
    > > > > > such
    > > > > > > > as
    > > > > > > > > (CustomersOrders) in the DataSet1.xsd file to populate the
    > > > > > dropdownlist.
    > > > > > > > >
    > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > > > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > With regards to your application, I still think there is
    an
    > > > easier
    > > > > > way
    > > > > > > > to
    > > > > > > > > do
    > > > > > > > > > that. I am sure you know that by now, but just to be safe:
    > You
    > > > > need
    > > > > > be
    > > > > > > > > aware
    > > > > > > > > > that typed datasets don't write the code for you to access
    > and
    > > > > > > retrieve
    > > > > > > > > > data. You still need to do all the loading/saving etc.
    > > yourself
    > > > in
    > > > > > > code.
    > > > > > > > > > Also, the databinding process for web controls does not
    > > > > > automatically
    > > > > > > > take
    > > > > > > > > > care of connected tables inside a dataset (typed or not),
    > you
    > > > also
    > > > > > > have
    > > > > > > > to
    > > > > > > > > > do this yourself.
    > > > > > > > > >
    > > > > > > > > > The straight-forward approach to solving your problem
    (using
    > > the
    > > > > > > > Northwind
    > > > > > > > > > database) is attached to this post on page webform1.aspx.
    > You
    > > > need
    > > > > > to
    > > > > > > > edit
    > > > > > > > > > the connection string and the sample is done using SQL
    > Server
    > > or
    > > > > > MSDE.
    > > > > > > > The
    > > > > > > > > > typed dataset version is on page webform2.aspx.
    > > > > > > > > >
    > > > > > > > > > And yes, I have remote desktop, so we can set up a time if
    > you
    > > > > want
    > > > > > to
    > > > > > > > and
    > > > > > > > > > I'll give it a quick look.
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > > > do you have remote desktop. I would like you to see want
    > I'm
    > > > > doing
    > > > > > > for
    > > > > > > > > > > yourself. I have did everything you stated, and have
    > > reference
    > > > > > > > multiple
    > > > > > > > > > > books and is yet to solve the problem. I thinking of
    > setting
    > > > up
    > > > > a
    > > > > > > > > > parameter
    > > > > > > > > > > stored procedure to get the state id to binding the
    right
    > > > > schools
    > > > > > > for
    > > > > > > > > that
    > > > > > > > > > > state in the dropdownlist. The reason I chose the .xsd
    > > > > relational
    > > > > > > > > dataset
    > > > > > > > > > > route, it easy to define relationships among tables.
    What
    > do
    > > > you
    > > > > > > > think?
    > > > > > > > > > >
    > > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in
    > message
    > > > > > > > > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > > Well, basically you can have VS.NET do the grunt work
    > for
    > > > you.
    > > > > > If
    > > > > > > > you
    > > > > > > > > > > > right-click on your project file, select add, then add
    > > > class,
    > > > > > > select
    > > > > > > > > > > dataset
    > > > > > > > > > > > and use any name you like (dataset1.xsd) is fine. Now
    > use
    > > > the
    > > > > > > server
    > > > > > > > > > > > explorer to drag a few tables in the XSD and use the
    > > toolbox
    > > > > to
    > > > > > > add
    > > > > > > > > > > > references and/or new fields as needed. Now, when you
    do
    > > > this
    > > > > > and
    > > > > > > > > > compile
    > > > > > > > > > > > your project, VS.NET will use a tool (XGEN.EXE) to
    > > generate
    > > > a
    > > > > C#
    > > > > > > > file
    > > > > > > > > > for
    > > > > > > > > > > > you that implements a strongly typed dataset. You can
    > use
    > > it
    > > > > > like
    > > > > > > > any
    > > > > > > > > > > other
    > > > > > > > > > > > dataset but it is also a strongly typed class with all
    > the
    > > > > > > > parameters
    > > > > > > > > > that
    > > > > > > > > > > > your tables have. You can also manually change the XSD
    > > file
    > > > or
    > > > > > use
    > > > > > > > the
    > > > > > > > > > GUI
    > > > > > > > > > > > to build your XSD from scratch.
    > > > > > > > > > > >
    > > > > > > > > > > > But if all you want to do is to fill two DropDownLists
    I
    > > > would
    > > > > > > > > recommend
    > > > > > > > > > > to
    > > > > > > > > > > > use the Data Access Application Blocks or simple
    ADO.NET
    > > to
    > > > > get
    > > > > > a
    > > > > > > > > > > DataTable
    > > > > > > > > > > > for each table separately and attach these to the
    > > > > dropdownlists.
    > > > > > > > > > > >
    > > > > > > > > > > > One other thing: you can help the databind process to
    > find
    > > > the
    > > > > > > right
    > > > > > > > > > > columns
    > > > > > > > > > > > to display by the user of DataTextField and
    > > DataValueField.
    > > > > For
    > > > > > > > > example,
    > > > > > > > > > > if
    > > > > > > > > > > > you have a DataTable with 4 columns (Company, Street,
    > > > Country,
    > > > > > > > > > CompanyID)
    > > > > > > > > > > > and you want the ddl to display the Company as text
    and
    > > have
    > > > > the
    > > > > > > > > > CompanyID
    > > > > > > > > > > > as the value you'd do something like this:
    > > > > > > > > > > >
    > > > > > > > > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > > > > > > > > MyDropDownList.DataTextField = "Company";
    > > > > > > > > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > > > >
    > > > > > > > > > > > Hope this helps!!
    > > > > > > > > > > >
    > > > > > > > > > > > Best regards,
    > > > > > > > > > > >
    > > > > > > > > > > > Marc Höppner
    > > > > > > > > > > > NeoGeo
    > > > > > > > > > > >
    > > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > > > > > Ok I have call the adatper.fill and databind
    command,
    > > but
    > > > > > is'nt
    > > > > > > > some
    > > > > > > > > > > type
    > > > > > > > > > > > of
    > > > > > > > > > > > > code such as
    > > > > > > Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > > > > > > > > "DataSet1.xsd" I have to type to get the database
    > schema
    > > > > from
    > > > > > > the
    > > > > > > > > .xsd
    > > > > > > > > > > > file
    > > > > > > > > > > > > (I have two relate tables in my .xsd file "States"
    and
    > > > > > "School".
    > > > > > > > > when
    > > > > > > > > > > you
    > > > > > > > > > > > > select a state from the first dropdownlist the
    second
    > > > > > > dropdownlist
    > > > > > > > > > > suppose
    > > > > > > > > > > > > to populate itself with the correct schools from
    that
    > > > state.
    > > > > > > > > However,
    > > > > > > > > > > the
    > > > > > > > > > > > > first list populate with the states, (I have
    > > autopostback
    > > > > set
    > > > > > to
    > > > > > > > > true,
    > > > > > > > > > > and
    > > > > > > > > > > > > the onchange event firing) but after the page
    postback
    > > the
    > > > > > state
    > > > > > > > > > > > > dropdownlist displays System.Data.RelatedView over
    and
    > > > over
    > > > > > > again.
    > > > > > > > > > > Thanks
    > > > > > > > > > > > > for the help!
    > > > > > > > > > > > >
    > > > > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in
    > > > message
    > > > > > > > > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > > > > Hi Leon,
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > configuring a typed dataset only gets you halfway
    > > there
    > > > > > > > (assuming
    > > > > > > > > > > that's
    > > > > > > > > > > > > > what you are doing with the XSD). What you still
    > need
    > > to
    > > > > do
    > > > > > by
    > > > > > > > > hand
    > > > > > > > > > is
    > > > > > > > > > > > to
    > > > > > > > > > > > > > write some ADO.NET code to establish the
    connection
    > > with
    > > > > the
    > > > > > > > > > database
    > > > > > > > > > > > and
    > > > > > > > > > > > > to
    > > > > > > > > > > > > > actually load stuff in your dataset. For example,
    > you
    > > > > could
    > > > > > > > define
    > > > > > > > > a
    > > > > > > > > > > > > > SqlDataAdapter, specify a SELECT... query and use
    > > .Fill
    > > > > with
    > > > > > > > your
    > > > > > > > > > > typed
    > > > > > > > > > > > > > DataSet as parameter (if you use SQL Server). It
    may
    > > be
    > > > a
    > > > > > > little
    > > > > > > > > > > > overkill
    > > > > > > > > > > > > to
    > > > > > > > > > > > > > define a typed dataset and use a DataAdapter only
    to
    > > > fill
    > > > > > two
    > > > > > > > > > > > > dropdownlists.
    > > > > > > > > > > > > > Take a look at the Data Access Application
    > > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > > > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it
    > could
    > > > be
    > > > > as
    > > > > > > > easy
    > > > > > > > > as
    > > > > > > > > > > > this
    > > > > > > > > > > > > > (C#):
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet(
    > > > > MyConnectionString,
    > > > > > > > > > > > > > CommandType.Text, "select name, value from
    > mytable" );
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > > > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > > > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > Note that using a dataset always has some
    overhead,
    > so
    > > > you
    > > > > > may
    > > > > > > > > want
    > > > > > > > > > to
    > > > > > > > > > > > use
    > > > > > > > > > > > > a
    > > > > > > > > > > > > > SqlDataReader for performance.
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > Best regards,
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > Marc Hoeppner
    > > > > > > > > > > > > > NeoGeo
    > > > > > > > > > > > > >
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > > > > > > > > After configuring a relation data schema
    > > > (MyDataSet.xsd)
    > > > > > in
    > > > > > > > > > vs.net,
    > > > > > > > > > > > what
    > > > > > > > > > > > > > > code do you use to display that data within two
    > > > > > dropdownlist
    > > > > > > > > > > controls
    > > > > > > > > > > > (
    > > > > > > > > > > > > > > parent/child) in an web application?
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > >
    > > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Leon Shaw Guest

  13. #13

    Default Re: XSD VS.Net

    Excellent, glad to be of help!

    "Leon Shaw" <vnality@msn.com> wrote in message
    news:OumP7$xSDHA.2276@TK2MSFTNGP10.phx.gbl...
    > Thanks So Much! I will surely apply and share the knowledge.
    > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > news:OwIWglxSDHA.2256@TK2MSFTNGP11.phx.gbl...
    > > Great, congrats!!
    > >
    > > A dataset is very powerfull on the one hand, but on the other has a lot
    of
    > > overhead. So you need to use it appropriately. Yes, you don't need a
    > dataset
    > > to fill a dropdownlist, but you also have to count other factors such as
    > > ease of use and amount of code to type. So, I'd use something similar to
    > the
    > > webform1.aspx approach and make sure that the page caching is set to a
    > long
    > > time period if your data does not changes very often. This way you have
    > the
    > > ease of use as in the first sample, but the database code only gets
    called
    > a
    > > few times a time for example. So, this was selecting data.
    > > Inserting/updating data can be done by a dataset as well, but if you
    only
    > > update a few items in a form you can as well use an SPROC and send it
    the
    > > values from your form directly without a dataset. If you have a larger
    > > application and use data over and over again on different pages, it may
    be
    > a
    > > good idea to build a couple of typed datasets where appropriate and use
    > them
    > > both for selecting and for inserting/updating.
    > >
    > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > news:egfNRBxSDHA.2460@TK2MSFTNGP10.phx.gbl...
    > > > I GOT IT TO WORK. THANKS SO MUCH, but so What you are saying is that I
    > > don't
    > > > even have to use a dataset at all. All I really need to do is use
    > > > sqlcommands to pull data into my form for easy selection Then use a
    > > dataset
    > > > to pull all the information from every form field and update the
    > database?
    > > > Correct
    > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > news:OcZIe3wSDHA.2128@TK2MSFTNGP12.phx.gbl...
    > > > > The method used in webform1.aspx should be a lot better than using
    > typed
    > > > > datasets in this case. Depending on your scenario you could some
    > caching
    > > > or
    > > > > even load all the orders (in this case) in a dataset if all
    customers
    > > get
    > > > > selected pretty frequently.
    > > > >
    > > > > If you still shoot for the typed dataset, you can start with the
    > > > > webform2.aspx sample and go from there. You can change the sample to
    > use
    > > > > SPROCs instead of inline SQL, but you still will have to do the
    > > filtering
    > > > of
    > > > > the dataset either in T-SQL or by use of the Select or Filter
    > functions
    > > in
    > > > > DataSet/DataTable manually.
    > > > > :)
    > > > >
    > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > news:OzY2jKwSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > > is that a better way, and more efficient way of doing it? However,
    > > > Thanks
    > > > > > for all the help!
    > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > news:%23QHDd8vSDHA.3132@tk2msftngp13.phx.gbl...
    > > > > > > Yes, you can do that!
    > > > > > >
    > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > news:%23WQEPcvSDHA.632@tk2msftngp13.phx.gbl...
    > > > > > > > So I should set up a store procedure in my MS SQL 2000
    database
    > > for
    > > > > > cities
    > > > > > > > (@StateID) and get the StateDropDownList.DataValueField and
    pass
    > > > that
    > > > > > > value
    > > > > > > > (@StateID) to display the correct Schools in the
    > > SchoolDropDownlist?
    > > > > > > > Correct!
    > > > > > > >
    > > > > > > >
    > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in message
    > > > > > > > news:uJ6XvKvSDHA.2852@tk2msftngp13.phx.gbl...
    > > > > > > > > I am not sure I get what you want to do. Could you elaborate
    a
    > > > > little?
    > > > > > > > >
    > > > > > > > > webform2.aspx is not good going practice at all as I load
    all
    > > > > > customers
    > > > > > > > and
    > > > > > > > > all orders into the typed dataset. I think webform1.aspx is
    a
    > > > much,
    > > > > > much
    > > > > > > > > better implementation (faster, easier to read, easier to
    > change,
    > > > > > > > faster...).
    > > > > > > > >
    > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > news:%23FTMkTtSDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > how do do that same code but reference the name of the
    > > > > relationship
    > > > > > > such
    > > > > > > > > as
    > > > > > > > > > (CustomersOrders) in the DataSet1.xsd file to populate the
    > > > > > > dropdownlist.
    > > > > > > > > >
    > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in
    message
    > > > > > > > > > news:esvEU3qSDHA.1684@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > With regards to your application, I still think there is
    > an
    > > > > easier
    > > > > > > way
    > > > > > > > > to
    > > > > > > > > > do
    > > > > > > > > > > that. I am sure you know that by now, but just to be
    safe:
    > > You
    > > > > > need
    > > > > > > be
    > > > > > > > > > aware
    > > > > > > > > > > that typed datasets don't write the code for you to
    access
    > > and
    > > > > > > > retrieve
    > > > > > > > > > > data. You still need to do all the loading/saving etc.
    > > > yourself
    > > > > in
    > > > > > > > code.
    > > > > > > > > > > Also, the databinding process for web controls does not
    > > > > > > automatically
    > > > > > > > > take
    > > > > > > > > > > care of connected tables inside a dataset (typed or
    not),
    > > you
    > > > > also
    > > > > > > > have
    > > > > > > > > to
    > > > > > > > > > > do this yourself.
    > > > > > > > > > >
    > > > > > > > > > > The straight-forward approach to solving your problem
    > (using
    > > > the
    > > > > > > > > Northwind
    > > > > > > > > > > database) is attached to this post on page
    webform1.aspx.
    > > You
    > > > > need
    > > > > > > to
    > > > > > > > > edit
    > > > > > > > > > > the connection string and the sample is done using SQL
    > > Server
    > > > or
    > > > > > > MSDE.
    > > > > > > > > The
    > > > > > > > > > > typed dataset version is on page webform2.aspx.
    > > > > > > > > > >
    > > > > > > > > > > And yes, I have remote desktop, so we can set up a time
    if
    > > you
    > > > > > want
    > > > > > > to
    > > > > > > > > and
    > > > > > > > > > > I'll give it a quick look.
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > news:eolD3IoSDHA.1916@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > > > > do you have remote desktop. I would like you to see
    want
    > > I'm
    > > > > > doing
    > > > > > > > for
    > > > > > > > > > > > yourself. I have did everything you stated, and have
    > > > reference
    > > > > > > > > multiple
    > > > > > > > > > > > books and is yet to solve the problem. I thinking of
    > > setting
    > > > > up
    > > > > > a
    > > > > > > > > > > parameter
    > > > > > > > > > > > stored procedure to get the state id to binding the
    > right
    > > > > > schools
    > > > > > > > for
    > > > > > > > > > that
    > > > > > > > > > > > state in the dropdownlist. The reason I chose the .xsd
    > > > > > relational
    > > > > > > > > > dataset
    > > > > > > > > > > > route, it easy to define relationships among tables.
    > What
    > > do
    > > > > you
    > > > > > > > > think?
    > > > > > > > > > > >
    > > > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote in
    > > message
    > > > > > > > > > > > news:OcWOLGlSDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > > > Well, basically you can have VS.NET do the grunt
    work
    > > for
    > > > > you.
    > > > > > > If
    > > > > > > > > you
    > > > > > > > > > > > > right-click on your project file, select add, then
    add
    > > > > class,
    > > > > > > > select
    > > > > > > > > > > > dataset
    > > > > > > > > > > > > and use any name you like (dataset1.xsd) is fine.
    Now
    > > use
    > > > > the
    > > > > > > > server
    > > > > > > > > > > > > explorer to drag a few tables in the XSD and use the
    > > > toolbox
    > > > > > to
    > > > > > > > add
    > > > > > > > > > > > > references and/or new fields as needed. Now, when
    you
    > do
    > > > > this
    > > > > > > and
    > > > > > > > > > > compile
    > > > > > > > > > > > > your project, VS.NET will use a tool (XGEN.EXE) to
    > > > generate
    > > > > a
    > > > > > C#
    > > > > > > > > file
    > > > > > > > > > > for
    > > > > > > > > > > > > you that implements a strongly typed dataset. You
    can
    > > use
    > > > it
    > > > > > > like
    > > > > > > > > any
    > > > > > > > > > > > other
    > > > > > > > > > > > > dataset but it is also a strongly typed class with
    all
    > > the
    > > > > > > > > parameters
    > > > > > > > > > > that
    > > > > > > > > > > > > your tables have. You can also manually change the
    XSD
    > > > file
    > > > > or
    > > > > > > use
    > > > > > > > > the
    > > > > > > > > > > GUI
    > > > > > > > > > > > > to build your XSD from scratch.
    > > > > > > > > > > > >
    > > > > > > > > > > > > But if all you want to do is to fill two
    DropDownLists
    > I
    > > > > would
    > > > > > > > > > recommend
    > > > > > > > > > > > to
    > > > > > > > > > > > > use the Data Access Application Blocks or simple
    > ADO.NET
    > > > to
    > > > > > get
    > > > > > > a
    > > > > > > > > > > > DataTable
    > > > > > > > > > > > > for each table separately and attach these to the
    > > > > > dropdownlists.
    > > > > > > > > > > > >
    > > > > > > > > > > > > One other thing: you can help the databind process
    to
    > > find
    > > > > the
    > > > > > > > right
    > > > > > > > > > > > columns
    > > > > > > > > > > > > to display by the user of DataTextField and
    > > > DataValueField.
    > > > > > For
    > > > > > > > > > example,
    > > > > > > > > > > > if
    > > > > > > > > > > > > you have a DataTable with 4 columns (Company,
    Street,
    > > > > Country,
    > > > > > > > > > > CompanyID)
    > > > > > > > > > > > > and you want the ddl to display the Company as text
    > and
    > > > have
    > > > > > the
    > > > > > > > > > > CompanyID
    > > > > > > > > > > > > as the value you'd do something like this:
    > > > > > > > > > > > >
    > > > > > > > > > > > > MyDropDownList.DataSource = MyDataTable;
    > > > > > > > > > > > > MyDropDownList.DataTextField = "Company";
    > > > > > > > > > > > > MyDropDownList.DataValueField = "CompanyID";
    > > > > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > > > > >
    > > > > > > > > > > > > Hope this helps!!
    > > > > > > > > > > > >
    > > > > > > > > > > > > Best regards,
    > > > > > > > > > > > >
    > > > > > > > > > > > > Marc Höppner
    > > > > > > > > > > > > NeoGeo
    > > > > > > > > > > > >
    > > > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > > > news:%23GrrRwkSDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > > > > > > > > > > > > Ok I have call the adatper.fill and databind
    > command,
    > > > but
    > > > > > > is'nt
    > > > > > > > > some
    > > > > > > > > > > > type
    > > > > > > > > > > > > of
    > > > > > > > > > > > > > code such as
    > > > > > > > Me.DataSet1.WriteXmlSchema(Me.Request.ApplicationP ath
    > > > > > > > > > > > > > "DataSet1.xsd" I have to type to get the database
    > > schema
    > > > > > from
    > > > > > > > the
    > > > > > > > > > .xsd
    > > > > > > > > > > > > file
    > > > > > > > > > > > > > (I have two relate tables in my .xsd file "States"
    > and
    > > > > > > "School".
    > > > > > > > > > when
    > > > > > > > > > > > you
    > > > > > > > > > > > > > select a state from the first dropdownlist the
    > second
    > > > > > > > dropdownlist
    > > > > > > > > > > > suppose
    > > > > > > > > > > > > > to populate itself with the correct schools from
    > that
    > > > > state.
    > > > > > > > > > However,
    > > > > > > > > > > > the
    > > > > > > > > > > > > > first list populate with the states, (I have
    > > > autopostback
    > > > > > set
    > > > > > > to
    > > > > > > > > > true,
    > > > > > > > > > > > and
    > > > > > > > > > > > > > the onchange event firing) but after the page
    > postback
    > > > the
    > > > > > > state
    > > > > > > > > > > > > > dropdownlist displays System.Data.RelatedView over
    > and
    > > > > over
    > > > > > > > again.
    > > > > > > > > > > > Thanks
    > > > > > > > > > > > > > for the help!
    > > > > > > > > > > > > >
    > > > > > > > > > > > > > "Marc Hoeppner" <marchoeppner@hotmail.com> wrote
    in
    > > > > message
    > > > > > > > > > > > > > news:OxAy7dkSDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > > > > > > > > > > > > Hi Leon,
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > configuring a typed dataset only gets you
    halfway
    > > > there
    > > > > > > > > (assuming
    > > > > > > > > > > > that's
    > > > > > > > > > > > > > > what you are doing with the XSD). What you still
    > > need
    > > > to
    > > > > > do
    > > > > > > by
    > > > > > > > > > hand
    > > > > > > > > > > is
    > > > > > > > > > > > > to
    > > > > > > > > > > > > > > write some ADO.NET code to establish the
    > connection
    > > > with
    > > > > > the
    > > > > > > > > > > database
    > > > > > > > > > > > > and
    > > > > > > > > > > > > > to
    > > > > > > > > > > > > > > actually load stuff in your dataset. For
    example,
    > > you
    > > > > > could
    > > > > > > > > define
    > > > > > > > > > a
    > > > > > > > > > > > > > > SqlDataAdapter, specify a SELECT... query and
    use
    > > > .Fill
    > > > > > with
    > > > > > > > > your
    > > > > > > > > > > > typed
    > > > > > > > > > > > > > > DataSet as parameter (if you use SQL Server). It
    > may
    > > > be
    > > > > a
    > > > > > > > little
    > > > > > > > > > > > > overkill
    > > > > > > > > > > > > > to
    > > > > > > > > > > > > > > define a typed dataset and use a DataAdapter
    only
    > to
    > > > > fill
    > > > > > > two
    > > > > > > > > > > > > > dropdownlists.
    > > > > > > > > > > > > > > Take a look at the Data Access Application
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > >
    > > > >
    > > >
    > >
    >
    Blocks([url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx[/url]
    > > > > > > > > > > > > > > ?pull=/library/en-us/dnbda/html/daab-rm.asp), it
    > > could
    > > > > be
    > > > > > as
    > > > > > > > > easy
    > > > > > > > > > as
    > > > > > > > > > > > > this
    > > > > > > > > > > > > > > (C#):
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > DataSet MyDs = SqlHelper.ExecuteDataSet(
    > > > > > MyConnectionString,
    > > > > > > > > > > > > > > CommandType.Text, "select name, value from
    > > mytable" );
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > MyDropDownList.DataSource = MyDs.Tables[0];
    > > > > > > > > > > > > > > MyDropDownList.DataTextField = "name";
    > > > > > > > > > > > > > > MyDropDownList.DataValueField = "value";
    > > > > > > > > > > > > > > MyDropDownList.DataBind();
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > Note that using a dataset always has some
    > overhead,
    > > so
    > > > > you
    > > > > > > may
    > > > > > > > > > want
    > > > > > > > > > > to
    > > > > > > > > > > > > use
    > > > > > > > > > > > > > a
    > > > > > > > > > > > > > > SqlDataReader for performance.
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > Best regards,
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > Marc Hoeppner
    > > > > > > > > > > > > > > NeoGeo
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > "Leon Shaw" <vnality@msn.com> wrote in message
    > > > > > > > > > > > > > > news:OXK2hxjSDHA.3796@tk2msftngp13.phx.gbl...
    > > > > > > > > > > > > > > > After configuring a relation data schema
    > > > > (MyDataSet.xsd)
    > > > > > > in
    > > > > > > > > > > vs.net,
    > > > > > > > > > > > > what
    > > > > > > > > > > > > > > > code do you use to display that data within
    two
    > > > > > > dropdownlist
    > > > > > > > > > > > controls
    > > > > > > > > > > > > (
    > > > > > > > > > > > > > > > parent/child) in an web application?
    > > > > > > > > > > > > > > >
    > > > > > > > > > > > > > > >
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > > >
    > > > > > > > > > > > > >
    > > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Marc Hoeppner Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139