小生做毕业设计,需要用通过Web Services把一个dataset传给FLASH接收,
FLASH不能直接识别.net里的dataset,要转换成数组才可以.我的方法如下,不知道怎么把dataset传给一个数组;
news里的字段是title,content,time请各位大侠帮忙了[WebMethod]
public  string GetDataSet_flash()
{
string conStr="Data Source=localhost;Initial catalog=web; User ID=sa;PWD=;";
SqlConnection con ;
con = new SqlConnection(conStr);
string selectStr = "select top 5 * from news order by id DESC";   SqlCommand  select;
select = new SqlCommand (selectStr,con);
select.Connection.Open();
SqlDataAdapter show;
show = new SqlDataAdapter(selectStr,con);
DataSet da=new DataSet ();
show.Fill(da,"news");            

         return da;
}

解决方案 »

  1.   

    有三个字段要换成数组的话 将是三维数组 
    flash能接收吗?
      

  2.   

    对,Flash能接受什么样的数组?
    是多维数组(array[a,b,c]),还是交错数组(array[a][b][c])?
      

  3.   

    比较简单的转换。
    ArrayList arr=new ArrayList();
    for(int i=0;i<ds.Tables[0].Columns.Count;i++)
    {
    arr.Add(ds.Tables[0].Rows[0][i].ToString());
    }
    return arr;
      

  4.   

    你可以创建一个二维数组,
    int row = da.Tables["new"].Rows.Count;
    int col = da.Tables["new"].Columns.Count;
    object[,] array = new object[row, col];