Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I nee to display result to textbox

What I have tried:

select SUM(CAST(REPLACE(iznos_sa_pdv,'.', '.')AS decimal(18,2)))  
from mp_kasa_lista   
WHERE datum >= CONVERT(datetime, convert(varchar(10), GETDATE() ,120), 120) AND datum < DATEADD(day, 1, convert(datetime, convert(varchar(10), getdate(), 120), 120))  
  AND tip_placanja='Virman'   
Posted
Updated 19-May-18 10:17am
Comments
Goran Bibic 19-May-18 14:06pm    
Result value from sql is 582.00

private void virman()
       {

           string sqlquery = ("select SUM(CAST(REPLACE(iznos_sa_pdv,'.', '.')AS decimal(18,2))) from mp_kasa_lista WHERE datum >= CONVERT(datetime, convert(varchar(10), GETDATE(), 120), 120) AND datum < DATEADD(day, 1, convert(datetime, convert(varchar(10), getdate(), 120), 120))  AND tip_placanja = 'Virman'   ");

           using (SqlConnection con = new SqlConnection(cs))
           {

           SqlCommand command = new SqlCommand(sqlquery, con);
               con.Open();


               SqlDataReader sdr = command.ExecuteReader();

           virmantextBox.Text = sdr.ToString();
               sdr.Close();
           con.Close();

           }

       }


Error is in textbox is result :
System.Data.SqlClient.SqlDataReader
 
Share this answer
 
Comments
Goran Bibic 19-May-18 16:17pm    
Solved
Richard Deeming 21-May-18 15:13pm    
If you want to update your question, click the green "Improve question" link and edit your question.

DO NOT post your update as a "solution".
Goran Bibic 22-May-18 2:20am    
Ok. Thank you. Sorry
string sqlquery = ("select SUM(CAST(REPLACE(iznos_sa_pdv,'.', '.')AS decimal(18,2))) as ukupno from mp_kasa_lista WHERE datum >= CONVERT(datetime, convert(varchar(10), GETDATE(), 120), 120) AND datum < DATEADD(day, 1, convert(datetime, convert(varchar(10), getdate(), 120), 120))  AND tip_placanja = 'Virman'");

           using (SqlConnection con = new SqlConnection(cs))
           {

           SqlCommand command = new SqlCommand(sqlquery, con);
               con.Open();


               SqlDataReader sdr = command.ExecuteReader();
               if (sdr.Read())

               {
                    virmantextBox.Text = (sdr["ukupno"].ToString());
                  // virmantextBox.Text = (sdr.ToString());

               }
               sdr.Close();
           con.Close();

           }
 
Share this answer
 

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