注册 登录
编程论坛 VB.NET论坛

大家帮助看一下,哪里错了

hezhifang 发布于 2007-12-15 15:11, 1416 次点击
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim olecon As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=d:\info.mdb;jet oledb:database password=123")
        Dim olestr As String = "select 密码 from info"
        Dim olecmd As New OleDbCommand(olestr, olecon)
        Dim olereader As OleDbDataReader
        olecon.Open()
        olereader = olecmd.ExecuteReader
        olereader.Read()
        If TextBox1.Text = olereader.GetString(0).Trim Then
            If TextBox2.Text = TextBox3.Text Then
                olereader.Close()
                = CommandType.Text
                = "update info set 密码=" & TextBox2.Text.Trim
                olecmd.ExecuteNonQuery()
            Else
                MsgBox("两次密码输入不一致!")
            End If
        Else
            MsgBox("原密码不正确!")
        End If
        olecon.Close()
    End Sub

运行后,提示至少有一个参数没有被指定值  好像是
= "update info set 密码=" & TextBox2.Text.Trim
没有给值,还是我写法错误呀
6 回复
#2
fairy42007-12-15 15:34
= "update info set 密码='" & TextBox2.Text.Trim"'"
試試看
#3
hezhifang2007-12-15 15:39
不行呀fairy4 怎么sql语言写法这么麻烦呀
#4
hezhifang2007-12-15 15:43
谢谢  fairy4我知道怎么写了

= "update info set 密码='" & TextBox2.Text.Trim & "'"
#5
fairy42007-12-15 16:25
我少打了個&,汗!!
#6
bygg2007-12-16 13:53
原帖由 [bold][underline]hezhifang[/underline][/bold] 于 2007-12-15 15:43 发表 [url=http://bbs.bc-cn.net/redirect.php?goto=findpost&pid=1149229&ptid=192609][/url]
谢谢  fairy4我知道怎么写了

= "update info set 密码='" & TextBox2.Text.Trim & "'"

你这样不是把数据库中这张表中的所有密码都改了??
#7
fairy42007-12-17 08:28
樓主的是批量更改密碼!呵呵!
有空的時候加個條件就是了!
1