Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Pls Help Me.How To do This in easy Method.Select query in one line.Thanks in advance

C#
string qry = "select advtcountryid from advt where advtcountryid='" + countryid + "'";
        string qry1 = "select agencycountryid from agency where agencycountryid='" + countryid + "'";
        string qry2 = "select clientcountryid from client where clientcountryid='" + countryid + "'";
        string qry3 = "select statecountryid from state where statecountryid='" + countryid + "'";
        MySqlConnection con =new MySqlConnection(common.GetConnectionString());
        MySqlDataReader dr = new MySqlDataReader();
        MySqlTransaction tran = con.BeginTransaction(IsolationLevel.ReadCommitted);
        MySqlCommand cmd = new MySqlCommand(qry, con, tran);
        cmd.Transaction = tran;
        dr = cmd.ExecuteReader();
        dr.Read();
        cmd.CommandText = qry1;
        cmd.ExecuteNonQuery();
        cmd.CommandText = qry2;
        cmd.ExecuteNonQuery();
        cmd.CommandText = qry3;
        cmd.ExecuteNonQuery();
Posted
Comments
Zoltán Zörgő 6-Jan-13 3:02am    
What exactly would be this "easy Method"?
pankajgarg1986 6-Jan-13 3:13am    
how to execute multiple select query in easy way

u have do somthing like this query........

C#
string qry=select a.advtcountryid ,ag.agencycountryid,c.clientcountryid ,s.statecountryid  from agency a,agency ag,client c,state  s
 where a.advtcountryid='" + countryid + "' and ag.agencycountryid='" + countryid + "' and c.clientcountryid='" + countryid + "' and s.countryid + ='" + countryid + "'";
 
Share this answer
 
Comments
pankajgarg1986 6-Jan-13 23:03pm    
Thanks Pallavi waikar.Nice reply form you.i really thanksfull to you
pankajgarg1986 6-Jan-13 23:08pm    
What why this query return Large amount of rows.In databse there are less records something 30 rows.but this query returns 308 rows.Pls find solution.
Pallavi Waikar 7-Jan-13 0:57am    
how should i know his database...i wrote here he has to use joins and have some connection in then..that was an exampal...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900