Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello
I have this error
{"An expression of non-boolean type specified in a context where a condition is expected, near ','."}

and how on this code add value form database to button so when i click it button has his own value

What I have tried:

on this code can you help me please
  CON.Open();
            string SQLQUERY = "SELECT * FROM HRANA WHERE (Naziv,Slika)VALUES (@Naziv, @slika) ";
            CMD = new SqlCommand(SQLQUERY, CON);
            CMD.Parameters.AddWithValue("@Naziv", button24.Text);
CMD.Parameters.Add(new SqlParameter("@slika", button24.Image));
            int N = CMD.ExecuteNonQuery();
            CON.Close();
Posted
Updated 14-Aug-17 3:00am

1 solution

"SELECT * FROM HRANA WHERE (Naziv,Slika)VALUES (@Naziv, @slika)

Your SELECT statement is formatted as though it were an INSERT statement.
You should review SQL a lot!

SQL Tutorial[^]

 
Share this answer
 
Comments
Member 13084733 14-Aug-17 10:48am    
so it should be ?

("SELECT Id FROM HRANA WHERE Naziv=@Naziv,Slika=@SLika);
Member 13084733 14-Aug-17 10:50am    
But how to add value to this button from column @Vrijednost
W Balboos, GHB 14-Aug-17 10:58am    
Don't play guessing games . . . study how SQL is done and do it right.
That's why I gave you the link.
Member 13084733 14-Aug-17 13:10pm    
I am not guessing it is this statement but i am more intrested for the second question regarding value of the button

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