2014-10-05 32 views
0

IM花費過多時間用於這種錯誤,無法在這裏找到錯誤列數並不在行匹配值計數1

Adapter = New MySqlDataAdapter("Insert into tbluser(UserID,Name,UserType,Password) values('" & txtUserId.Text & "' ,'" & txtName.Text & "','" & cmbUserType.Text & "','" & "',AES_ENCRYPT('" & txtpass.Text & "','x'))", connection) 
+1

a)您敞開SQL注入二)永遠不會存儲密碼 - 哈希它來代替;也看起來像一個數據類型不匹配param 1 – Plutonix 2014-10-05 15:50:52

+0

'適配器=新MySqlDataAdapter(「插入tbluser(UserID,名稱,用戶類型,密碼)值('」&txtUserId.Text&「','」&txtName.Text&「' ,''&cmbUserType.Text&「',AES_ENCRYPT(''&txtpass.Text&」','x'))「,connection)'試試這個 – 2014-10-05 15:51:03

+0

將SQL語句分配給一個字符串,然後將其打印出來。用結果編輯你的問題。這是一個參數替換的問題,所以看看你在做什麼,問題可能會很明顯。 – 2014-10-05 15:51:20

回答

0
Adapter = New MySqlDataAdapter("Insert into tbluser (UserID 
               ,Name 
               ,UserType 
               ,Password) 
          values('" & txtUserId.Text & "' 
            , '" & txtName.Text & "' 
            , '" & cmbUserType.Text & "' 
            , '" & "' 
            , AES_ENCRYPT('" & txtpass.Text & "','x'))", connection) 

您有更多的價值比你定義列插。它看起來像是UserType和密碼之間的空白字段。修改它像這樣應該可以解決列計數錯誤:

Adapter = New MySqlDataAdapter("Insert into tbluser (UserID 
                , Name 
                , UserType 
                , Password) 
             values('" & txtUserId.Text & "' 
              , '" & txtName.Text & "' 
              , '" & cmbUserType.Text & "' 
              , AES_ENCRYPT('" & txtpass.Text & "','x'))" 
           , connection) 
相關問題