Tema: SQL count
View Single Post
Staro 22.10.2010., 09:06   #3
Fadolf
Premium
 
Fadolf's Avatar
 
Datum registracije: Dec 2007
Lokacija: Zagabria
Postovi: 492
Samo bih ti preporučio da koristiš parametriziranje kako bi spriječio SQL injection...

Dodaj System.Data namespace prvo...

Code:
string selectString = ("SELECT count(username) FROM tabela WHERE username= @username"); 
SqlCommand mySqlCommand = new SqlCommand(selectString,mySqlConnection); 
mySqlCommand.Parameters.Add("@username", SqlDbType.String).Value = textbox1.Text;
int count = (int)mySqlCommand.ExecuteScalar();
Fadolf je offline   Reply With Quote