标题:[求助]密码修改为什么不能回写到数据库?
取消只看楼主
xuegao
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2007-4-3
 问题点数:0 回复次数:1 
[求助]密码修改为什么不能回写到数据库?

希望大家帮帮忙,谢谢各位拉!
具体代码如下Imports System.Data.SqlClient
Public Class 密码修改
Dim mycn As New SqlConnection("Data Source =(local);Initial Catalog =教师信息管理系统;Integrated Security=SSPI")
Dim mycommand As New SqlCommand

Function DataCheck(ByVal a As String, ByVal b As String) As Boolean

mycommand.CommandText = "Select count(*) From 密码表" & _
" Where 用户名= '" & a & "'and 密码 = '" & b & "'"
mycommand.Connection = mycn

If mycommand.ExecuteScalar = 0 Then
Return True
Else
Return False
End If
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim username As String
Dim userpaw As String
username = txtusername.Text
userpaw = txtouserpaw.Text
Try
mycn.Open()
If DataCheck(username, userpaw) = True Then

MsgBox("用户名和密码不存在,请重新输入")
Else

If txtnuserpaw1.Text = txtnuserpaw2.Text Then

mycommand.CommandType = CommandType.Text
mycommand.CommandText = "Update 密码表 set 密码 =' " & txtnuserpaw2.Text.Trim & "'Where 用户名 =' " & txtusername.Text.Trim & "'"
mycommand.Connection = mycn

mycommand.ExecuteNonQuery()

MsgBox("密码修改成功!!")

Else
MsgBox("前后2次密码不一致!!")
End If

End If


Catch ex As Exception

MsgBox(ex.Message)
Finally
mycn.Close()

End Try

End Sub

搜索更多相关主题的帖子: 密码 数据库 信息管理系统 
2007-06-29 09:56
xuegao
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2007-4-3
得分:0 

哦 谢谢拉

2007-06-29 21:42



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-151224-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.088409 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved