好,所以很容易在VB,但我不能算出它在C#:添加變量串在ASP.net
SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM tblUsers WHERE username = '" & username & "'", cn);
這將引發
CS0019: Operator '&' cannot be applied to operands of type 'string' and 'string'
Google搜索,並能找不到答案,請幫助這個新手在這裏!
使用+運算符而不是&運算符。 – adatapost 2010-08-05 14:46:39
選擇COUNT(*)FROM tblUsers WHERE username ='「+ username +」OR 1 = 1'「,cn); – Paco 2010-08-05 14:52:34
Paco,這就是黑客如何爲「用戶名」輸入一個垃圾值,以使您的查詢始終爲真。 – 2010-08-05 14:53:28