Adding a column to a datatable

Discussion in 'ASP .Net' started by Tina, Jun 25, 2004.

  1. Tina

    Tina Guest

    I'm doing this...

    Dim dt As New DataTable

    dt.Columns.Add("AreaGroup", Type.GetType("System.String"))

    dt.Columns.Add("Col1", Type.GetType("System.String"))

    dt.Columns.Add("Col2", Type.GetType("System.decimal"))

    it works ok when I specify System.String but when I specify System.decimal I
    get an exception saying...

    'dataType' argument cannot be null. Parameter name: dataType

    Why?
    T
     
    Tina, Jun 25, 2004
    #1
    1. Advertisements

  2. Tina

    Teemu Keiski Guest

    Hi,

    not sure if it is case-sensitive but type name is "System.Decimal" (Decimal
    with the first character in uppercase)
     
    Teemu Keiski, Jun 25, 2004
    #2
    1. Advertisements

  3. Tina

    siid

    Joined:
    May 7, 2012
    Messages:
    1
    Likes Received:
    0
    Answer

    "Tina" <> wrote in message
    news:...
    > I'm doing this...
    >
    > Dim dt As New DataTable
    >
    > dt.Columns.Add("AreaGroup", Type.GetType("System.String"))
    >
    > dt.Columns.Add("Col1", Type.GetType("System.String"))
    >
    > dt.Columns.Add("Col2", Type.GetType("System.Decimal"))
    >
    > it works ok when I specify System.String but when I specify System.decimal
    I
    > get an exception saying...
    >
    > 'dataType' argument cannot be null. Parameter name: dataType
    >
    > Why?
    > T
    >Answer []:
    Keep first letter capital
    eg: System.Decimal
    System.Double

    This will make your code work:congrats:

    Thanks
    Siid.
     
    siid, May 7, 2012
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.