为什么 添加用户 老提示已存在?
添加用户 老提示已存在
Dim datable As New DataTable
m_dal.ConnectionOpen()
Dim sql As String
sql = "select * from 人员信息 where 员工号='" & Me.TextBox1.Text & "'"
m_dal.DataSetFill(sql, "员工号")
datable = m_dal.ds.Tables("员工号")
If datable.Rows.Count = 0 Then
ErrorProvider1.Clear()
sql = "insert into 人员信息(员工号,姓名,英文,密码,所在层,岗位,权限,登陆信息,登陆ip)"
sql += " values ('" & Me.TextBox1.Text & "','" & Me.TextBox2.Text & "','" & Me.TextBox3.Text & "','" & MyEncrypt(Me.TextBox4.Text) & "','" & Me.TextBox5.Text & "','" & Me.TextBox6.Text & "')"
m_dal.InsertDelUpdateRecord(sql)
m_dal.ConnectionClose()
Me.Label8.Text = "添加用户成功"
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox5.Text = ""
Me.TextBox6.Text = ""
Me.TextBox7.Text = ""
Else
ErrorProvider1.SetError(TextBox1, "员工号重复,请重新输入!")
Me.TextBox1.Text = ""
Me.TextBox1.Focus()
End If
添加用户时判断表中是否存在该员工号,有提示存在,重新输入。否则直接添加该用户。
但不知为啥老提示已存在,表中只有一条用户记录呀??、
Me.TextBox6.Text = ""
Me.TextBox7.Text = ""
If
[解决办法]