Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2014
    Posts
    23

    Unanswered: Cannot find table 0.

    I'm using C# and I'm trying to convert a number into a DateTime.

    I believe the way to do it is to pull it into a dataset and edit the value in there.

    Code:
            using (iDB2Connection conn = new iDB2Connection(connect))
            {
                using (iDB2Command cmd = new iDB2Command(query, conn))
                {
                    conn.Open();
                    iDB2DataAdapter da = new iDB2DataAdapter(cmd);
                    DataSet ds = new DataSet();
                    foreach (DataRow dRow in ds.Tables["0"].Rows)
                    {
                        string atc = dRow["VUATC"].ToString();
                        DateTime lat = DateTime.Parse(dRow["VUATC"].ToString());
                    }
                    da.Fill(ds);
                    GridView1.DataSource = ds;
                    GridView1.DataBind();
                    GridView1.GridLines = GridLines.Horizontal;
    I get this error.

    System.IndexOutOfRangeException: Cannot find table 0.

    Sorry if I made two threads.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    How is the number formatted? Give us three examples of your numbers and the dates that they represent.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jan 2014
    Posts
    23
    I'm trying to convert two numbers. They're in different columns though.

    1743 > 5:43
    901 > 9:01
    1701 > 5:01

    1140103 > Century 1, 2014, January 3
    1140107 > Century 1, 2014, January 7
    1131220 > Century 1, 2013, December 20

  4. #4
    Join Date
    Jan 2014
    Posts
    23
    Sorry for the late reply. I think my first reply was unapproved for some reason, but I didn't get any notification.

    I'm trying to parse two columns.

    The first value is 1546 which translates to 3:46 pm.

    The second value is 1140111 which translates to 1st century, 2014 January 11 in that order.
    Last edited by EiBot; 01-13-14 at 17:29.

  5. #5
    Join Date
    Jan 2014
    Posts
    23
    Bump.

    My first reply must have been suspicious due to the majority of its content is mostly numbers, so it was delayed.

    In any case, I would still like some help with this problem if anyone's willing.

  6. #6
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    I'm not sure that this is a DB2 problem. You should try on a C# forum.
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  7. #7
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'd suggest using ParseExact() with a format identifier instead of using Parse().

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

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