Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling a typed dataset with multiple tables

Status
Not open for further replies.

robert201

Programmer
Jul 18, 2007
80
TH
Hello,

VS 2005

I am using MySql as my database. I can fill individual tables, however when I query to select from 2 different tables and do an add watch on the dataset the count for those 2 tables is 0.

Everything runs without errors. However, when I check count property for the table in the add watch it gives an zero.

However, if I write the query like this: "SELECT * FROM Beverage"
and fill using this da.Fill(DS.Beverage); Then the count display the correct number of rows.

Can anyone explain this?

Many thanks,

My code for filling
Code:
 try
            {
                this.OpenConnection();

                RestaurantDataSet ds = new RestaurantDataSet();
                MySqlDataAdapter da = new MySqlDataAdapter();
                MySqlCommand cmd = new MySqlCommand();

                cmd.Connection = cnn;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT maincourse.MainCourseID, beverage.BeverageID FROM maincourse, beverage";
                                    
                da.SelectCommand = cmd;
                da.Fill(ds);

                return ds;      
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
 
I hate to start from zero, but have you run the query against the MySql DB through another means? I mean, if your query returns two tables, the code as written should put two tables in the dataset. And the fact that the dataset is showing two tables (although with no rows) would lead me to believe that the problem is the query.

If the query is taking some parameters, perhaps that is causing it to return zero rows?

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top