列数与第1行的值计数不匹配

时间:2014-10-05 15:48:41

标签: mysql sql vb.net

我花了太多时间来处理此错误,但无法在此处找到错误

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

1 个答案:

答案 0 :(得分: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和Password之间的空字段。像这样修改它应该解决列计数错误:

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