use parameter when populating a struct with dataset c#?
I have a struct in a web service in c#. When I use "Select * from TABLE1"; in a WebMethod I get a fully populated struct. But when I add a WHERE clause, I get null in response. Why is this? I have searched everywhere for a simple explanation but haven't found one.
How can I use a SELECT * FROM TABLE1 WHERE _id=" + id "'"; If I only want to retrieve a single post from the database it works fine, but not when I get a multiple row response. 
Is there also a way of ordering a multiple-row response any way in c#?
Thanks in advance!
edit :
DataSet myDS = new DataSet();
   try开发者_运维技巧
   {
       myConnection.Open();
       // Fill dataset with account data
       //myCommand.Fill(myDS, "userdata");
       myAdapter.Fill(myDS, "toplista");
       myConnection.Close();
       int i = myDS.Tables["toplista"].Rows.Count;
       toplista[] mytoplista = new toplista[i];
       i = 0;
       foreach (DataRow row in myDS.Tables["toplista"].Rows)
       {
           mytoplista[i].name = row["_name"].ToString();
           mytoplista[i].points = int.Parse(row["_points"].ToString());
           mytoplista[i].level = row["_level"].ToString();
           i++;
       }
       return mytoplista;
Am I understanding correctly that your struct represents a single tuple from your table? If that's the case, you should either be trying to populate an IEnumerable<MyStruct> or only getting the first matching row out of your table. Otherwise, what do you expect it to do with the rest of the data that gets returned?
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论