Tema: SQL count
View Single Post
Staro 22.10.2010., 00:07   #1
high5
Registered User
 
Datum registracije: Aug 2009
Lokacija: N/A
Postovi: 46
SQL count

Pozz ljudi,

Npr, hoću da prebrojim sve one koji se zovu "dario"(prepostavimo da se u bazi nalazi jedan "dario"):

string selectString = ("SELECT count(username) FROM tabela WHERE username= ' " + textBox1.Text + " '");
SqlCommand mySqlCommand = new SqlCommand(selectString,mySqlConnection);
int count = (int)mySqlCommand.ExecuteScalar();

Kao rezultat mi vraća 0. Međutim kad postavim ovo vraća mi 1 kao sto i je.

string selectString = ("SELECT count(username) FROM tabela WHERE username='dario');
SqlCommand mySqlCommand = new SqlCommand(selectString,mySqlConnection);
int count = (int)mySqlCommand.ExecuteScalar();

Zasto u prvom primjeru ne vraća 1.
high5 je offline   Reply With Quote