0
     SqlDataAdapter da = new SqlDataAdapter("select d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,d18,d19,d20,d21,d22,d23,d24,d25,d26,d27,d28,d29,d30, name from jully  where batch=" + "'" + s_batch + "'" +
    "and semester=" + "'" + s_semester + "'" + "and shift=" + "'" + s_shift + "'"+"and rolno="+rolno, conn);
     DataTable dt = new DataTable();
     conn.Open();
     da.Fill(dt);

     for (int i = 0; i < dt.Columns.Count; i++)
     {
        hhh[i] = dt.Columns[].ToString();
     }
0

3 Answers 3

1

Depending what exactly you expect the type of hhh to be, you could do something like

hhh = dt.AsEnumerable().ToArray();

which would give you an array of DataRows

hhh = dt.AsEnumerable().Select(row => row.ItemArray).ToArray();

which would give you a jagged array - an array of arrays of object, one array for each row

Sign up to request clarification or add additional context in comments.

Comments

0
     SqlDataAdapter da = new SqlDataAdapter("select d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,d18,d19,d20,d21,d22,d23,d24,d25,d26,d27,d28,d29,d30, name from jully  where batch=" + "'" + s_batch + "'" +
        "and semester=" + "'" + s_semester + "'" + "and shift=" + "'" + s_shift + "'"+"and rolno="+rolno, conn);
         DataTable dt = new DataTable();
         conn.Open();
         da.Fill(dt);

         for (int i = 0; i < dt.rows.Count; i++)
         { for (int j = 0; j < dt.columns.Count; j++)
            hhh[k] = dt.rows[i][j].tostring();
k++;
         }

Comments

0

Try this:

string[] hhh = new string[dt.Columns.Count];
for (int i = 0; i < dt.Columns.Count; i++)
{
    hhh[i] = dt.Columns[i].ToString();
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.