Row filtering

Discussion in 'ASP .Net' started by =?Utf-8?B?c2lhag==?=, Feb 24, 2005.

  1. Hi all,
    I am having a dataset which is Reading from the XML file. The Dataset has a
    table Users with Scheema (US_ID, US_Name). I am attempting to add new user to
    this table. for this I want to fetch the max US_ID , increment by One and add
    to table
    The code is
    maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    The issue I am facing is that I am not getting proper maxID as US_ID is
    interpreted as char while reading.
    I also tried using the cast expression but I m getting syntax error.

    any suggestion will be highly appreciated...

    Cheers,
    siaj
    =?Utf-8?B?c2lhag==?=, Feb 24, 2005
    #1
    1. Advertising

  2. Have you tried converting it to a number?

    Let me explain the difference between casting and converting. Casting is
    done when a data type IS the type being cast to. IOW, the data type is
    either the target type or it is inherited from the target type. You can cast
    a System.Web.UI.Page as a System.Web.UI.Control because it inherits
    System.Web.UI.Control. It IS a System.Web.UI.Control.

    Converting is done when the type IS NOT the same data type as the target
    type. Strings, for example, can not be CAST as integers; they are not in any
    sense integers. However, they can, if they are strings of numbers, be
    CONVERTED to integers.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "siaj" <> wrote in message
    news:...
    > Hi all,
    > I am having a dataset which is Reading from the XML file. The Dataset has
    > a
    > table Users with Scheema (US_ID, US_Name). I am attempting to add new user
    > to
    > this table. for this I want to fetch the max US_ID , increment by One and
    > add
    > to table
    > The code is
    > maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    > The issue I am facing is that I am not getting proper maxID as US_ID is
    > interpreted as char while reading.
    > I also tried using the cast expression but I m getting syntax error.
    >
    > any suggestion will be highly appreciated...
    >
    > Cheers,
    > siaj
    >
    >
    Kevin Spencer, Feb 24, 2005
    #2
    1. Advertising

  3. Thanks for the Reply but casting works in SQL server atleast
    for eg :
    USE foodMart
    GO
    SELECT * FROM salary WHERE employee_ID =(SELECT MAX (CAST(employee_ID as
    int)) FROM salary)

    Although I had tried using convert also but it does not helps ...

    Cheers,
    siaj

    "Kevin Spencer" wrote:

    > Have you tried converting it to a number?
    >
    > Let me explain the difference between casting and converting. Casting is
    > done when a data type IS the type being cast to. IOW, the data type is
    > either the target type or it is inherited from the target type. You can cast
    > a System.Web.UI.Page as a System.Web.UI.Control because it inherits
    > System.Web.UI.Control. It IS a System.Web.UI.Control.
    >
    > Converting is done when the type IS NOT the same data type as the target
    > type. Strings, for example, can not be CAST as integers; they are not in any
    > sense integers. However, they can, if they are strings of numbers, be
    > CONVERTED to integers.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > ..Net Developer
    > Neither a follower nor a lender be.
    >
    > "siaj" <> wrote in message
    > news:...
    > > Hi all,
    > > I am having a dataset which is Reading from the XML file. The Dataset has
    > > a
    > > table Users with Scheema (US_ID, US_Name). I am attempting to add new user
    > > to
    > > this table. for this I want to fetch the max US_ID , increment by One and
    > > add
    > > to table
    > > The code is
    > > maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    > > The issue I am facing is that I am not getting proper maxID as US_ID is
    > > interpreted as char while reading.
    > > I also tried using the cast expression but I m getting syntax error.
    > >
    > > any suggestion will be highly appreciated...
    > >
    > > Cheers,
    > > siaj
    > >
    > >

    >
    >
    >
    =?Utf-8?B?c2lhag==?=, Feb 24, 2005
    #3
  4. > Thanks for the Reply but casting works in SQL server atleast

    Casting works for fishing too, but I wouldn't try to use that sort of
    casting in a .Net application.

    Just because the same term is used, and even has a -similar- meaning in 2
    different software packages doesn't mean that it IS the same. Using CAST in
    SQL Server is NOT the same as casting in a .Net app. Apples and oranges are
    both fruit, but they sure don't taste the same!

    Re-read my explanation of casting and converting in .Net.

    I would attempt to help you more, but you've provided no new information.
    All you've said is that you "tried" some unknown thing ("Using Convert" -
    whatever that means in specific terms), and that, for some reason, "it does
    not helps." For example, if you went to an auto parts store, and told them
    you needed a carbeurator, which they sold to you, and you went home and
    tried to install it, and it didn't work, they would want to know HOW you
    tried to install it, and what specifically happened when you did (how did
    your car behave?). For example, you might have tried to bolt it to your
    steering wheel, for all they know.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "siaj" <> wrote in message
    news:...
    > Thanks for the Reply but casting works in SQL server atleast
    > for eg :
    > USE foodMart
    > GO
    > SELECT * FROM salary WHERE employee_ID =(SELECT MAX (CAST(employee_ID as
    > int)) FROM salary)
    >
    > Although I had tried using convert also but it does not helps ...
    >
    > Cheers,
    > siaj
    >
    > "Kevin Spencer" wrote:
    >
    >> Have you tried converting it to a number?
    >>
    >> Let me explain the difference between casting and converting. Casting is
    >> done when a data type IS the type being cast to. IOW, the data type is
    >> either the target type or it is inherited from the target type. You can
    >> cast
    >> a System.Web.UI.Page as a System.Web.UI.Control because it inherits
    >> System.Web.UI.Control. It IS a System.Web.UI.Control.
    >>
    >> Converting is done when the type IS NOT the same data type as the target
    >> type. Strings, for example, can not be CAST as integers; they are not in
    >> any
    >> sense integers. However, they can, if they are strings of numbers, be
    >> CONVERTED to integers.
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> ..Net Developer
    >> Neither a follower nor a lender be.
    >>
    >> "siaj" <> wrote in message
    >> news:...
    >> > Hi all,
    >> > I am having a dataset which is Reading from the XML file. The Dataset
    >> > has
    >> > a
    >> > table Users with Scheema (US_ID, US_Name). I am attempting to add new
    >> > user
    >> > to
    >> > this table. for this I want to fetch the max US_ID , increment by One
    >> > and
    >> > add
    >> > to table
    >> > The code is
    >> > maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    >> > The issue I am facing is that I am not getting proper maxID as US_ID is
    >> > interpreted as char while reading.
    >> > I also tried using the cast expression but I m getting syntax error.
    >> >
    >> > any suggestion will be highly appreciated...
    >> >
    >> > Cheers,
    >> > siaj
    >> >
    >> >

    >>
    >>
    >>
    Kevin Spencer, Feb 24, 2005
    #4
  5. Thanks for ur time and enlightening on fishing and AutoParts ... I was
    looking for some enlightening on some .net Issue..
    Meanwhile I tried the Rowfiltering as
    axIDRow = dsUser.Tables(0).Select("US_ID=(SELECT MAX (CONVERT(int,US_ID))
    FROM Users)")

    It gives Error
    Syntax error: Missing operand after 'MAX' operator.

    cheers,
    siaj


    "Kevin Spencer" wrote:

    > > Thanks for the Reply but casting works in SQL server atleast

    >
    > Casting works for fishing too, but I wouldn't try to use that sort of
    > casting in a .Net application.
    >
    > Just because the same term is used, and even has a -similar- meaning in 2
    > different software packages doesn't mean that it IS the same. Using CAST in
    > SQL Server is NOT the same as casting in a .Net app. Apples and oranges are
    > both fruit, but they sure don't taste the same!
    >
    > Re-read my explanation of casting and converting in .Net.
    >
    > I would attempt to help you more, but you've provided no new information.
    > All you've said is that you "tried" some unknown thing ("Using Convert" -
    > whatever that means in specific terms), and that, for some reason, "it does
    > not helps." For example, if you went to an auto parts store, and told them
    > you needed a carbeurator, which they sold to you, and you went home and
    > tried to install it, and it didn't work, they would want to know HOW you
    > tried to install it, and what specifically happened when you did (how did
    > your car behave?). For example, you might have tried to bolt it to your
    > steering wheel, for all they know.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > ..Net Developer
    > Neither a follower nor a lender be.
    >
    > "siaj" <> wrote in message
    > news:...
    > > Thanks for the Reply but casting works in SQL server atleast
    > > for eg :
    > > USE foodMart
    > > GO
    > > SELECT * FROM salary WHERE employee_ID =(SELECT MAX (CAST(employee_ID as
    > > int)) FROM salary)
    > >
    > > Although I had tried using convert also but it does not helps ...
    > >
    > > Cheers,
    > > siaj
    > >
    > > "Kevin Spencer" wrote:
    > >
    > >> Have you tried converting it to a number?
    > >>
    > >> Let me explain the difference between casting and converting. Casting is
    > >> done when a data type IS the type being cast to. IOW, the data type is
    > >> either the target type or it is inherited from the target type. You can
    > >> cast
    > >> a System.Web.UI.Page as a System.Web.UI.Control because it inherits
    > >> System.Web.UI.Control. It IS a System.Web.UI.Control.
    > >>
    > >> Converting is done when the type IS NOT the same data type as the target
    > >> type. Strings, for example, can not be CAST as integers; they are not in
    > >> any
    > >> sense integers. However, they can, if they are strings of numbers, be
    > >> CONVERTED to integers.
    > >>
    > >> --
    > >> HTH,
    > >>
    > >> Kevin Spencer
    > >> Microsoft MVP
    > >> ..Net Developer
    > >> Neither a follower nor a lender be.
    > >>
    > >> "siaj" <> wrote in message
    > >> news:...
    > >> > Hi all,
    > >> > I am having a dataset which is Reading from the XML file. The Dataset
    > >> > has
    > >> > a
    > >> > table Users with Scheema (US_ID, US_Name). I am attempting to add new
    > >> > user
    > >> > to
    > >> > this table. for this I want to fetch the max US_ID , increment by One
    > >> > and
    > >> > add
    > >> > to table
    > >> > The code is
    > >> > maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    > >> > The issue I am facing is that I am not getting proper maxID as US_ID is
    > >> > interpreted as char while reading.
    > >> > I also tried using the cast expression but I m getting syntax error.
    > >> >
    > >> > any suggestion will be highly appreciated...
    > >> >
    > >> > Cheers,
    > >> > siaj
    > >> >
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?c2lhag==?=, Feb 24, 2005
    #5
  6. > Thanks for ur time and enlightening on fishing and AutoParts ... I was
    > looking for some enlightening on some .net Issue..


    It's a shame that you thought I was talking about fishing and auto parts. I
    was giving you enlightenment on .Net issues by using analogies, but
    apparently you missed it.

    In fact, you MUST have missed it, because you're still trying to treat .Net
    executable code and classes as if they were SQL Server. Although the
    Expression used in a DataTable.Select() method is a string, just like SQL,
    it is NOT SQL. You just tried to bolt your new carbeurator to the steering
    column. You're trying to make apple sauce out of orange juice.

    The following reference concerning the Expression property of a DataColumn
    is the same rules as the expression you use with the Select() method of a
    DataTable (in fact I found it by looking up the Select() method of a
    DataTable), so don't go there and assume I am pointing you in the wrong
    direction:

    http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "siaj" <> wrote in message
    news:...
    > Thanks for ur time and enlightening on fishing and AutoParts ... I was
    > looking for some enlightening on some .net Issue..
    > Meanwhile I tried the Rowfiltering as
    > axIDRow = dsUser.Tables(0).Select("US_ID=(SELECT MAX (CONVERT(int,US_ID))
    > FROM Users)")
    >
    > It gives Error
    > Syntax error: Missing operand after 'MAX' operator.
    >
    > cheers,
    > siaj
    >
    >
    > "Kevin Spencer" wrote:
    >
    >> > Thanks for the Reply but casting works in SQL server atleast

    >>
    >> Casting works for fishing too, but I wouldn't try to use that sort of
    >> casting in a .Net application.
    >>
    >> Just because the same term is used, and even has a -similar- meaning in 2
    >> different software packages doesn't mean that it IS the same. Using CAST
    >> in
    >> SQL Server is NOT the same as casting in a .Net app. Apples and oranges
    >> are
    >> both fruit, but they sure don't taste the same!
    >>
    >> Re-read my explanation of casting and converting in .Net.
    >>
    >> I would attempt to help you more, but you've provided no new information.
    >> All you've said is that you "tried" some unknown thing ("Using Convert" -
    >> whatever that means in specific terms), and that, for some reason, "it
    >> does
    >> not helps." For example, if you went to an auto parts store, and told
    >> them
    >> you needed a carbeurator, which they sold to you, and you went home and
    >> tried to install it, and it didn't work, they would want to know HOW you
    >> tried to install it, and what specifically happened when you did (how did
    >> your car behave?). For example, you might have tried to bolt it to your
    >> steering wheel, for all they know.
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> ..Net Developer
    >> Neither a follower nor a lender be.
    >>
    >> "siaj" <> wrote in message
    >> news:...
    >> > Thanks for the Reply but casting works in SQL server atleast
    >> > for eg :
    >> > USE foodMart
    >> > GO
    >> > SELECT * FROM salary WHERE employee_ID =(SELECT MAX (CAST(employee_ID
    >> > as
    >> > int)) FROM salary)
    >> >
    >> > Although I had tried using convert also but it does not helps ...
    >> >
    >> > Cheers,
    >> > siaj
    >> >
    >> > "Kevin Spencer" wrote:
    >> >
    >> >> Have you tried converting it to a number?
    >> >>
    >> >> Let me explain the difference between casting and converting. Casting
    >> >> is
    >> >> done when a data type IS the type being cast to. IOW, the data type is
    >> >> either the target type or it is inherited from the target type. You
    >> >> can
    >> >> cast
    >> >> a System.Web.UI.Page as a System.Web.UI.Control because it inherits
    >> >> System.Web.UI.Control. It IS a System.Web.UI.Control.
    >> >>
    >> >> Converting is done when the type IS NOT the same data type as the
    >> >> target
    >> >> type. Strings, for example, can not be CAST as integers; they are not
    >> >> in
    >> >> any
    >> >> sense integers. However, they can, if they are strings of numbers, be
    >> >> CONVERTED to integers.
    >> >>
    >> >> --
    >> >> HTH,
    >> >>
    >> >> Kevin Spencer
    >> >> Microsoft MVP
    >> >> ..Net Developer
    >> >> Neither a follower nor a lender be.
    >> >>
    >> >> "siaj" <> wrote in message
    >> >> news:...
    >> >> > Hi all,
    >> >> > I am having a dataset which is Reading from the XML file. The
    >> >> > Dataset
    >> >> > has
    >> >> > a
    >> >> > table Users with Scheema (US_ID, US_Name). I am attempting to add
    >> >> > new
    >> >> > user
    >> >> > to
    >> >> > this table. for this I want to fetch the max US_ID , increment by
    >> >> > One
    >> >> > and
    >> >> > add
    >> >> > to table
    >> >> > The code is
    >> >> > maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    >> >> > The issue I am facing is that I am not getting proper maxID as US_ID
    >> >> > is
    >> >> > interpreted as char while reading.
    >> >> > I also tried using the cast expression but I m getting syntax
    >> >> > error.
    >> >> >
    >> >> > any suggestion will be highly appreciated...
    >> >> >
    >> >> > Cheers,
    >> >> > siaj
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
    Kevin Spencer, Feb 24, 2005
    #6
  7. Kevin, I appreciate ur helping attitude and I have gone thru the links u
    provided but the analogies and words like "shame" were definately not in
    good taste for aspirants of .Net. Phrases like this many times takes out the
    essence out of the good solutions.
    Usergroups are meant to help and encourage people not bashing and shaming
    people....

    Thanks for all....
    siaj


    "Kevin Spencer" wrote:

    > > Thanks for ur time and enlightening on fishing and AutoParts ... I was
    > > looking for some enlightening on some .net Issue..

    >
    > It's a shame that you thought I was talking about fishing and auto parts. I
    > was giving you enlightenment on .Net issues by using analogies, but
    > apparently you missed it.
    >
    > In fact, you MUST have missed it, because you're still trying to treat .Net
    > executable code and classes as if they were SQL Server. Although the
    > Expression used in a DataTable.Select() method is a string, just like SQL,
    > it is NOT SQL. You just tried to bolt your new carbeurator to the steering
    > column. You're trying to make apple sauce out of orange juice.
    >
    > The following reference concerning the Expression property of a DataColumn
    > is the same rules as the expression you use with the Select() method of a
    > DataTable (in fact I found it by looking up the Select() method of a
    > DataTable), so don't go there and assume I am pointing you in the wrong
    > direction:
    >
    > http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > ..Net Developer
    > Neither a follower nor a lender be.
    >
    > "siaj" <> wrote in message
    > news:...
    > > Thanks for ur time and enlightening on fishing and AutoParts ... I was
    > > looking for some enlightening on some .net Issue..
    > > Meanwhile I tried the Rowfiltering as
    > > axIDRow = dsUser.Tables(0).Select("US_ID=(SELECT MAX (CONVERT(int,US_ID))
    > > FROM Users)")
    > >
    > > It gives Error
    > > Syntax error: Missing operand after 'MAX' operator.
    > >
    > > cheers,
    > > siaj
    > >
    > >
    > > "Kevin Spencer" wrote:
    > >
    > >> > Thanks for the Reply but casting works in SQL server atleast
    > >>
    > >> Casting works for fishing too, but I wouldn't try to use that sort of
    > >> casting in a .Net application.
    > >>
    > >> Just because the same term is used, and even has a -similar- meaning in 2
    > >> different software packages doesn't mean that it IS the same. Using CAST
    > >> in
    > >> SQL Server is NOT the same as casting in a .Net app. Apples and oranges
    > >> are
    > >> both fruit, but they sure don't taste the same!
    > >>
    > >> Re-read my explanation of casting and converting in .Net.
    > >>
    > >> I would attempt to help you more, but you've provided no new information.
    > >> All you've said is that you "tried" some unknown thing ("Using Convert" -
    > >> whatever that means in specific terms), and that, for some reason, "it
    > >> does
    > >> not helps." For example, if you went to an auto parts store, and told
    > >> them
    > >> you needed a carbeurator, which they sold to you, and you went home and
    > >> tried to install it, and it didn't work, they would want to know HOW you
    > >> tried to install it, and what specifically happened when you did (how did
    > >> your car behave?). For example, you might have tried to bolt it to your
    > >> steering wheel, for all they know.
    > >>
    > >> --
    > >> HTH,
    > >>
    > >> Kevin Spencer
    > >> Microsoft MVP
    > >> ..Net Developer
    > >> Neither a follower nor a lender be.
    > >>
    > >> "siaj" <> wrote in message
    > >> news:...
    > >> > Thanks for the Reply but casting works in SQL server atleast
    > >> > for eg :
    > >> > USE foodMart
    > >> > GO
    > >> > SELECT * FROM salary WHERE employee_ID =(SELECT MAX (CAST(employee_ID
    > >> > as
    > >> > int)) FROM salary)
    > >> >
    > >> > Although I had tried using convert also but it does not helps ...
    > >> >
    > >> > Cheers,
    > >> > siaj
    > >> >
    > >> > "Kevin Spencer" wrote:
    > >> >
    > >> >> Have you tried converting it to a number?
    > >> >>
    > >> >> Let me explain the difference between casting and converting. Casting
    > >> >> is
    > >> >> done when a data type IS the type being cast to. IOW, the data type is
    > >> >> either the target type or it is inherited from the target type. You
    > >> >> can
    > >> >> cast
    > >> >> a System.Web.UI.Page as a System.Web.UI.Control because it inherits
    > >> >> System.Web.UI.Control. It IS a System.Web.UI.Control.
    > >> >>
    > >> >> Converting is done when the type IS NOT the same data type as the
    > >> >> target
    > >> >> type. Strings, for example, can not be CAST as integers; they are not
    > >> >> in
    > >> >> any
    > >> >> sense integers. However, they can, if they are strings of numbers, be
    > >> >> CONVERTED to integers.
    > >> >>
    > >> >> --
    > >> >> HTH,
    > >> >>
    > >> >> Kevin Spencer
    > >> >> Microsoft MVP
    > >> >> ..Net Developer
    > >> >> Neither a follower nor a lender be.
    > >> >>
    > >> >> "siaj" <> wrote in message
    > >> >> news:...
    > >> >> > Hi all,
    > >> >> > I am having a dataset which is Reading from the XML file. The
    > >> >> > Dataset
    > >> >> > has
    > >> >> > a
    > >> >> > table Users with Scheema (US_ID, US_Name). I am attempting to add
    > >> >> > new
    > >> >> > user
    > >> >> > to
    > >> >> > this table. for this I want to fetch the max US_ID , increment by
    > >> >> > One
    > >> >> > and
    > >> >> > add
    > >> >> > to table
    > >> >> > The code is
    > >> >> > maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    > >> >> > The issue I am facing is that I am not getting proper maxID as US_ID
    > >> >> > is
    > >> >> > interpreted as char while reading.
    > >> >> > I also tried using the cast expression but I m getting syntax
    > >> >> > error.
    > >> >> >
    > >> >> > any suggestion will be highly appreciated...
    > >> >> >
    > >> >> > Cheers,
    > >> >> > siaj
    > >> >> >
    > >> >> >
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?c2lhag==?=, Feb 24, 2005
    #7
  8. I wasn't bashing you, but since you come from a different country you may
    have thought I was. "I'ts a shame" is an English expression of "it's too
    bad".

    Here's an idea. Why don't you get the Max by looping through the DataTable?

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "siaj" <> wrote in message
    news:...
    > Kevin, I appreciate ur helping attitude and I have gone thru the links u
    > provided but the analogies and words like "shame" were definately not
    > in
    > good taste for aspirants of .Net. Phrases like this many times takes out
    > the
    > essence out of the good solutions.
    > Usergroups are meant to help and encourage people not bashing and shaming
    > people....
    >
    > Thanks for all....
    > siaj
    >
    >
    > "Kevin Spencer" wrote:
    >
    >> > Thanks for ur time and enlightening on fishing and AutoParts ... I was
    >> > looking for some enlightening on some .net Issue..

    >>
    >> It's a shame that you thought I was talking about fishing and auto parts.
    >> I
    >> was giving you enlightenment on .Net issues by using analogies, but
    >> apparently you missed it.
    >>
    >> In fact, you MUST have missed it, because you're still trying to treat
    >> .Net
    >> executable code and classes as if they were SQL Server. Although the
    >> Expression used in a DataTable.Select() method is a string, just like
    >> SQL,
    >> it is NOT SQL. You just tried to bolt your new carbeurator to the
    >> steering
    >> column. You're trying to make apple sauce out of orange juice.
    >>
    >> The following reference concerning the Expression property of a
    >> DataColumn
    >> is the same rules as the expression you use with the Select() method of a
    >> DataTable (in fact I found it by looking up the Select() method of a
    >> DataTable), so don't go there and assume I am pointing you in the wrong
    >> direction:
    >>
    >> http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> ..Net Developer
    >> Neither a follower nor a lender be.
    >>
    >> "siaj" <> wrote in message
    >> news:...
    >> > Thanks for ur time and enlightening on fishing and AutoParts ... I was
    >> > looking for some enlightening on some .net Issue..
    >> > Meanwhile I tried the Rowfiltering as
    >> > axIDRow = dsUser.Tables(0).Select("US_ID=(SELECT MAX
    >> > (CONVERT(int,US_ID))
    >> > FROM Users)")
    >> >
    >> > It gives Error
    >> > Syntax error: Missing operand after 'MAX' operator.
    >> >
    >> > cheers,
    >> > siaj
    >> >
    >> >
    >> > "Kevin Spencer" wrote:
    >> >
    >> >> > Thanks for the Reply but casting works in SQL server atleast
    >> >>
    >> >> Casting works for fishing too, but I wouldn't try to use that sort of
    >> >> casting in a .Net application.
    >> >>
    >> >> Just because the same term is used, and even has a -similar- meaning
    >> >> in 2
    >> >> different software packages doesn't mean that it IS the same. Using
    >> >> CAST
    >> >> in
    >> >> SQL Server is NOT the same as casting in a .Net app. Apples and
    >> >> oranges
    >> >> are
    >> >> both fruit, but they sure don't taste the same!
    >> >>
    >> >> Re-read my explanation of casting and converting in .Net.
    >> >>
    >> >> I would attempt to help you more, but you've provided no new
    >> >> information.
    >> >> All you've said is that you "tried" some unknown thing ("Using
    >> >> Convert" -
    >> >> whatever that means in specific terms), and that, for some reason, "it
    >> >> does
    >> >> not helps." For example, if you went to an auto parts store, and told
    >> >> them
    >> >> you needed a carbeurator, which they sold to you, and you went home
    >> >> and
    >> >> tried to install it, and it didn't work, they would want to know HOW
    >> >> you
    >> >> tried to install it, and what specifically happened when you did (how
    >> >> did
    >> >> your car behave?). For example, you might have tried to bolt it to
    >> >> your
    >> >> steering wheel, for all they know.
    >> >>
    >> >> --
    >> >> HTH,
    >> >>
    >> >> Kevin Spencer
    >> >> Microsoft MVP
    >> >> ..Net Developer
    >> >> Neither a follower nor a lender be.
    >> >>
    >> >> "siaj" <> wrote in message
    >> >> news:...
    >> >> > Thanks for the Reply but casting works in SQL server atleast
    >> >> > for eg :
    >> >> > USE foodMart
    >> >> > GO
    >> >> > SELECT * FROM salary WHERE employee_ID =(SELECT MAX
    >> >> > (CAST(employee_ID
    >> >> > as
    >> >> > int)) FROM salary)
    >> >> >
    >> >> > Although I had tried using convert also but it does not helps ...
    >> >> >
    >> >> > Cheers,
    >> >> > siaj
    >> >> >
    >> >> > "Kevin Spencer" wrote:
    >> >> >
    >> >> >> Have you tried converting it to a number?
    >> >> >>
    >> >> >> Let me explain the difference between casting and converting.
    >> >> >> Casting
    >> >> >> is
    >> >> >> done when a data type IS the type being cast to. IOW, the data type
    >> >> >> is
    >> >> >> either the target type or it is inherited from the target type. You
    >> >> >> can
    >> >> >> cast
    >> >> >> a System.Web.UI.Page as a System.Web.UI.Control because it inherits
    >> >> >> System.Web.UI.Control. It IS a System.Web.UI.Control.
    >> >> >>
    >> >> >> Converting is done when the type IS NOT the same data type as the
    >> >> >> target
    >> >> >> type. Strings, for example, can not be CAST as integers; they are
    >> >> >> not
    >> >> >> in
    >> >> >> any
    >> >> >> sense integers. However, they can, if they are strings of numbers,
    >> >> >> be
    >> >> >> CONVERTED to integers.
    >> >> >>
    >> >> >> --
    >> >> >> HTH,
    >> >> >>
    >> >> >> Kevin Spencer
    >> >> >> Microsoft MVP
    >> >> >> ..Net Developer
    >> >> >> Neither a follower nor a lender be.
    >> >> >>
    >> >> >> "siaj" <> wrote in message
    >> >> >> news:...
    >> >> >> > Hi all,
    >> >> >> > I am having a dataset which is Reading from the XML file. The
    >> >> >> > Dataset
    >> >> >> > has
    >> >> >> > a
    >> >> >> > table Users with Scheema (US_ID, US_Name). I am attempting to add
    >> >> >> > new
    >> >> >> > user
    >> >> >> > to
    >> >> >> > this table. for this I want to fetch the max US_ID , increment by
    >> >> >> > One
    >> >> >> > and
    >> >> >> > add
    >> >> >> > to table
    >> >> >> > The code is
    >> >> >> > maxID = dsUser.Tables(0).Select("US_ID=MAX(US_ID)")
    >> >> >> > The issue I am facing is that I am not getting proper maxID as
    >> >> >> > US_ID
    >> >> >> > is
    >> >> >> > interpreted as char while reading.
    >> >> >> > I also tried using the cast expression but I m getting syntax
    >> >> >> > error.
    >> >> >> >
    >> >> >> > any suggestion will be highly appreciated...
    >> >> >> >
    >> >> >> > Cheers,
    >> >> >> > siaj
    >> >> >> >
    >> >> >> >
    >> >> >>
    >> >> >>
    >> >> >>
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
    Kevin Spencer, Feb 24, 2005
    #8
    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. Craig
    Replies:
    2
    Views:
    2,861
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Nov 2, 2004
  2. Siegfried Heintze

    Wanted: Example of Row Filtering with DataView

    Siegfried Heintze, Sep 10, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    18,962
    Juan T. Llibre
    Sep 11, 2005
  3. D
    Replies:
    0
    Views:
    195
  4. matis
    Replies:
    0
    Views:
    108
    matis
    Aug 30, 2006
  5. siaj

    Row filtering

    siaj, Feb 24, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    130
Loading...

Share This Page