Click here to Skip to main content
12,626,813 members (35,910 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
Pls Help Me.How To do This in easy Method.Select query in one line.Thanks in advance

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 5-Jan-13 21:04pm
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

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

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 + "'";
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100