Can you answer this ?

Discussion in 'MCSD' started by cj, Jul 13, 2003.

  1. cj

    cj Guest

    I picked up a sample exam from Examsheets for the 070-315 exam and this was one of the questions.

    Your ASP.NET application enables customers to create new sales orders. The sales orders are stored in a Microsoft SQL Server database table. The table has an IDENTITY column named OrderID. Your code uses a DataTable object to manage the order data. The DataTable object contains a column named OrderNumber. You use the Update method of a SqlDataAdapter object to call a stored procedure that inserts each new order into the database. The stored procedure uses a parameter to returns the new OrderID value for each order.
    You assign a SqlCommand object to the InsertCommand property of the SqlDataAdapter object. You add a SqlParameter object to the Parameters collection of the SqlDataAdapter object, specifying the name and data type of the parameter.

    You need to set properties of the SqlParameter object to retrieve new OrderID values from the database into the OrderNumber column of your DataTable object.

    What should you do?

    A. Set the Direction property to ParameterDirection.ReturnValue. Set the SourceColumn property to "OrderID".

    B. Set the Direction property to ParameterDirection.ReturnValue. Set the SourceColumn property to "OrderNumber".

    C. Set the Direction property to ParameterDirection.Output. Set the SourceColumn property to "OrderID".

    D. Set the Direction property to ParameterDirection.Output. Set the SourceColumn property to "OrderNumber".

    The answer they gave was A, but that seems very wrong to me, since the SourceColumn should be the column in the datatable that the value is coming from or going into. My answer was B (since it says the SP returns the OrderID value I assumed it was a return value)

    Does anyone have any insight as to why that would be their answer, or are they wrong ?

    Cheers,

    CJ
    cj, Jul 13, 2003
    #1
    1. Advertising

  2. cj

    Simon Smith Guest

    On Sun, 13 Jul 2003 12:18:00 +0800 in article
    <> in
    microsoft.public.cert.exam.mcsd , "cj" <>
    wrote:

    >I picked up a sample exam from Examsheets for the 070-315 exam and this was one of the questions.
    >
    >Your ASP.NET application enables customers to create new sales orders. The sales orders are stored in a Microsoft SQL Server database table. The table has an IDENTITY column named OrderID. Your code uses a DataTable object to manage the order data. The DataTable object contains a column named OrderNumber. You use the Update method of a SqlDataAdapter object to call a stored procedure that inserts each new order into the database. The stored procedure uses a parameter to returns the new OrderID value for each order.
    >You assign a SqlCommand object to the InsertCommand property of the SqlDataAdapter object. You add a SqlParameter object to the Parameters collection of the SqlDataAdapter object, specifying the name and data type of the parameter.
    >
    >You need to set properties of the SqlParameter object to retrieve new OrderID values from the database into the OrderNumber column of your DataTable object.
    >
    >What should you do?
    >
    >A. Set the Direction property to ParameterDirection.ReturnValue. Set the SourceColumn property to "OrderID".
    >
    >B. Set the Direction property to ParameterDirection.ReturnValue. Set the SourceColumn property to "OrderNumber".
    >
    >C. Set the Direction property to ParameterDirection.Output. Set the SourceColumn property to "OrderID".
    >
    >D. Set the Direction property to ParameterDirection.Output. Set the SourceColumn property to "OrderNumber".
    >
    >The answer they gave was A, but that seems very wrong to me, since the SourceColumn should be the column in the datatable that the value is coming from or going into. My answer was B (since it says the SP returns the OrderID value I assumed it was a return value)
    >
    >Does anyone have any insight as to why that would be their answer, or are they wrong ?
    >
    >Cheers,


    From the question: "The stored procedure uses a parameter to returns
    the new OrderID value"

    You didn't read the question closely enough.

    Another clue: "The table has an IDENTITY column named OrderID."
    That's probably the one you want, then. (You understand that, don't
    you?)

    So the given answer of A is correct.

    You message came through to me full of HTML tags. This is hard to read
    in a text-only reader (and Usenet is a text-only medium) so I ignored
    the rest. Sorry.



    --
    Simon
    simon dot smith at snowvalley dot com
    "Insomnia is a small price to pay for the stuff you read on UseNet"
    Simon Smith, Jul 13, 2003
    #2
    1. Advertising

  3. cj

    Alan Davis Guest

    > So the given answer of A is correct.

    Interesting. It is common practice that return values from sql server
    store procedures should return only the status of the action i.e.
    success or failure, not the result of some operation.

    Simon Smith wrote:
    > On Sun, 13 Jul 2003 12:18:00 +0800 in article
    > <> in
    > microsoft.public.cert.exam.mcsd , "cj" <>
    > wrote:
    >
    >
    >>I picked up a sample exam from Examsheets for the 070-315 exam and this was one of the questions.
    >>
    >>Your ASP.NET application enables customers to create new sales orders. The sales orders are stored in a Microsoft SQL Server database table. The table has an IDENTITY column named OrderID. Your code uses a DataTable object to manage the order data. The DataTable object contains a column named OrderNumber. You use the Update method of a SqlDataAdapter object to call a stored procedure that inserts each new order into the database. The stored procedure uses a parameter to returns the new OrderID value for each order.
    >>You assign a SqlCommand object to the InsertCommand property of the SqlDataAdapter object. You add a SqlParameter object to the Parameters collection of the SqlDataAdapter object, specifying the name and data type of the parameter.
    >>
    >>You need to set properties of the SqlParameter object to retrieve new OrderID values from the database into the OrderNumber column of your DataTable object.
    >>
    >>What should you do?
    >>
    >>A. Set the Direction property to ParameterDirection.ReturnValue. Set the SourceColumn property to "OrderID".
    >>
    >>B. Set the Direction property to ParameterDirection.ReturnValue. Set the SourceColumn property to "OrderNumber".
    >>
    >>C. Set the Direction property to ParameterDirection.Output. Set the SourceColumn property to "OrderID".
    >>
    >>D. Set the Direction property to ParameterDirection.Output. Set the SourceColumn property to "OrderNumber".
    >>
    >>The answer they gave was A, but that seems very wrong to me, since the SourceColumn should be the column in the datatable that the value is coming from or going into. My answer was B (since it says the SP returns the OrderID value I assumed it was a return value)
    >>
    >>Does anyone have any insight as to why that would be their answer, or are they wrong ?
    >>
    >>Cheers,

    >
    >
    > From the question: "The stored procedure uses a parameter to returns
    > the new OrderID value"
    >
    > You didn't read the question closely enough.
    >
    > Another clue: "The table has an IDENTITY column named OrderID."
    > That's probably the one you want, then. (You understand that, don't
    > you?)
    >
    > So the given answer of A is correct.
    >
    > You message came through to me full of HTML tags. This is hard to read
    > in a text-only reader (and Usenet is a text-only medium) so I ignored
    > the rest. Sorry.
    >
    >
    >
    Alan Davis, Jul 13, 2003
    #3
  4. cj

    Yakov Guest

    imho, A is correct.
    As I understand 'returnValue' refers to SQL. Not to your
    DataSet/DataTable.

    >You need to set properties of the SqlParameter object to

    retrieve new OrderID values from the database into the
    OrderNumber column of your DataTable object.

    >A. Set the Direction property to

    ParameterDirection.ReturnValue. Set the SourceColumn
    property to "OrderID".
    Yakov, Jul 14, 2003
    #4
  5. cj

    Yakov Guest

    On the second thought, I'm giving up :)

    "to retrieve new OrderID values from the database into the
    OrderNumber column of your DataTable object."

    This phrase confusing me. Why would you set OrderID to
    OrderNumber.. and how (using DataAdapter).

    So, sorry folks, I don't know the answer.
    Yakov, Jul 14, 2003
    #5
  6. cj

    Vineet Guest

    Hi.. I might sound nieve however.. i would like to ask shouldnt the
    answer be

    C. Set the Direction property to ParameterDirection.Output. Set the
    SourceColumn property to "OrderID".

    beacause we are using a parameter in StoredProc and I guess we use
    ParameterDirection.Output when we use parameter in a SP.. and Return
    Value other wise. I would be very happy if you could correct me..

    Thanks,
    ~V

    "Yakov" <> wrote in message news:<037f01c349b5$91da0ac0$>...
    > imho, A is correct.
    > As I understand 'returnValue' refers to SQL. Not to your
    > DataSet/DataTable.
    >
    > >You need to set properties of the SqlParameter object to

    > retrieve new OrderID values from the database into the
    > OrderNumber column of your DataTable object.
    >
    > >A. Set the Direction property to

    > ParameterDirection.ReturnValue. Set the SourceColumn
    > property to "OrderID".
    Vineet, Jul 14, 2003
    #6
  7. cj

    Alan Davis Guest

    Correct.

    Vineet wrote:
    > Hi.. I might sound nieve however.. i would like to ask shouldnt the
    > answer be
    >
    > C. Set the Direction property to ParameterDirection.Output. Set the
    > SourceColumn property to "OrderID".
    >
    > beacause we are using a parameter in StoredProc and I guess we use
    > ParameterDirection.Output when we use parameter in a SP.. and Return
    > Value other wise. I would be very happy if you could correct me..
    >
    > Thanks,
    > ~V
    >
    > "Yakov" <> wrote in message news:<037f01c349b5$91da0ac0$>...
    >
    >>imho, A is correct.
    >>As I understand 'returnValue' refers to SQL. Not to your
    >>DataSet/DataTable.
    >>
    >>
    >>>You need to set properties of the SqlParameter object to

    >>
    >>retrieve new OrderID values from the database into the
    >>OrderNumber column of your DataTable object.
    >>
    >>
    >>>A. Set the Direction property to

    >>
    >>ParameterDirection.ReturnValue. Set the SourceColumn
    >>property to "OrderID".
    Alan Davis, Jul 14, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    570
    Walter Roberson
    Sep 2, 2005
  2. Zadkin

    Wrong answer equals to a blank answer or not?

    Zadkin, Jun 23, 2006, in forum: Microsoft Certification
    Replies:
    8
    Views:
    757
    Cerebrus
    Jun 27, 2006
  3. sara_love67
    Replies:
    7
    Views:
    544
    Ima Beech
    Sep 25, 2007
  4. V
    Replies:
    11
    Views:
    647
    Neil Simpson
    Jan 23, 2004
  5. Rick
    Replies:
    7
    Views:
    309
    Consultant
    Aug 18, 2003
Loading...

Share This Page