hi
i have some problem with my sql code
that the code :

SELECT * FROM MenUsers,WomenUsers

MenUsers(Table) and WomenUsers(Table)

whats the problem with this code?
thanks....

hi
i have some problem with my sql code
that the code :

SELECT * FROM MenUsers,WomenUsers

MenUsers(Table) and WomenUsers(Table)

whats the problem with this code?
thanks....

Your code is right and seems to have no problem.... Can you please explain the problem you are encountering?

i have this problem:

when i try this:

public UsersDetails(string sql)
        {
            dbConnection dbc = new dbConnection();
            DataSet ds = new DataSet();         
            ds = dbc.Read(sql);

                if (ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No Details");
                }
                else
                {
                 .....
                }

when sql = "SELECT * FROM MenUsers" i get the Details (ds.Tables[0].Rows.Count != 0)
but when sql = "SELECT * FROM MenUsers,WomenUsers" i get eror "No Detaild" (ds.Tables[0].Rows.Count == 0)

and also when i try to do like this if (ds.Tables[1].Rows.Count == 0) ... i get eror.
i dont know why??

Edited 5 Years Ago by moshe12007: n/a

Why dont you better create two dataTable for Men and Women, and put both into the dataSet?

using (SqlConnection sqlConn = new SqlConnection("connString"))
            {
                DataSet ds = new DataSet();
                SqlDataAdapter da;
                SqlCommand cmd;
                DataTable table1 = new DataTable("Men");
                DataTable table2=new DataTable("Women");
                //fill men`s table:
                string query1 = @"SELECT * FROM Men";
                cmd = new SqlCommand(query1, sqlConn);
                da = new SqlDataAdapter(cmd);
                da.Fill(table1);
                //fill women`s table:
                string query2 = @"SELECT * FROM Women";
                cmd = new SqlCommand(query2, sqlConn);
                da = new SqlDataAdapter(cmd);
                da.Fill(table2);
            }

no i dont wanna like this code cause that problem with my another code.
i need inm this way : "SELECT * FROM MenUsers,WomenUsers"
i also try " SELECT * FROM MenUsers AND WomenUsers" but not work!!!
please help me

your query SELECT * FROM MenUsers,WomenUsers has no syntax problem check for the records in both the tables

your query SELECT * FROM MenUsers,WomenUsers has no syntax problem check for the records in both the tables

what you mean "check for the records in both the tables"?
i try this:

sql = "SELECT * FROM MenUsers,WomenUsers";

DataSet Read(string sql)
        {        
                DataSet ds = new DataSet();
                try
                {
                    SqlConnection conn = new SqlConnection(connStr);
                    SqlCommand cmd = new SqlCommand(sql, conn);

                    conn.Open();
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    adapter.Fill(ds); 
                    conn.Close();
                }
                catch
                {
                    MessageBox.Show("cant to read");
                }

and in another function:

dbConnection dbc = new dbConnection();
            DataSet ds = new DataSet();
            ds = dbc.Read(sql);

and in this function i use this:

if (ds.Tables[0].Rows.Count == 0)
.....
if (ds.Tables[1].Rows.Count == 0)

and i get error ...
why?

try this code

con = new MySqlConnection();
     con.ConnectionString = "Your Connection String";
     string sql = "SELECT * FROM table1,table2;";
     adpter = new MySqlDataAdapter(sql, con);
     adpter.Fill(ds);
     if (ds.Tables[0].Rows.Count == 0)
     {
        MessageBOx.Show("NO Details in Table1");
     }

Edited 5 Years Ago by __avd: Added [code]..[/code] tags.

your query SELECT * FROM MenUsers,WomenUsers has no syntax problem check for the records in both the tables

As he said!
If your both tables DO NOT have the same column names, this is impossible to select.

This article has been dead for over six months. Start a new discussion instead.