how to assign database value to arrays. i tried like this…
da = new SqlDataAdapter("select emname from emp", con);
ds = new DataSet();
da.Fill(ds, "emp");
if(ds.Tables [0].Rows.Count >0)
{
for(int i=0;i<ds.Tables [0].Rows .Count ;i++)
{
string[] myArray = ds.Tables[0].Rows[i]["emname"].ToString();
}
}
but it is giving error that can’t convert string to string[]
please help me
Try this:
Note that there are neater ways of doing this using LINQ, but if you’re quite new to C#/.NET I’d advise you to become familiar with the basics before diving into LINQ.