Abhilash J A

Abhilash J A

  • 501
  • 2.4k
  • 598.1k

How to use two select query ado.net c#?

Oct 17 2016 10:01 AM
Hello Everyone,
 
I want to select full data from First query and only select count from Second query. After, I want to get these both query result in to the userList
 
 But, now getting error:- "
SQL logic error or missing database
near "select": syntax error
"
  1.  string sql = "SELECT * FROM Tble_UserSetUp inner join Tble_Login on Tble_UserSetUp.Id = Tble_Login.UserId WHERE Tble_Login.UserId='" + Userid + "'";  
  2.             sql += "select count(*) from Tble_UserSetUp inner join Tble_Documents on Tble_Documents.UserId = Tble_UserSetUp.Id where Tble_Documents.UserId ='" + Userid + "'";  
  3.             DataTable dt = new DataTable();  
  4.             DataTable dt1 = new DataTable();  
  5.             // DataSet ds = new DataSet();  
  6.             try  
  7.             {  
  8.                 using (SQLiteConnection con = new SQLiteConnection(dbConnection))  
  9.                 {  
  10.                     using (SQLiteCommand cmd = new SQLiteCommand(sql))  
  11.                     {  
  12.                         using (SQLiteDataAdapter da = new SQLiteDataAdapter())  
  13.                         {  
  14.                             cmd.Connection = con;  
  15.                             da.SelectCommand = cmd;  
  16.                             using (DataSet ds = new DataSet())  
  17.                             {  
  18.                                 da.Fill(ds);  
  19.                                 dt = ds.Tables[0];  
  20.                                 dt1 = ds.Tables[1];  
  21.                             }  
  22.                         }  
  23.                     }  
  24.                     con.Close();  
  25.                 }  
  26.   
  27.                 var userList = from myRow in dt.AsEnumerable()  
  28.                                where myRow.Field<bool>("IsActive1") == true  
  29.                                select myRow;  

Answers (3)