编程论坛's Archiver

hezhifang 发表于 2007-12-15 15:11

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

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()
                olecmd.CommandType = CommandType.Text
                olecmd.CommandText = "update info set 密码=" & TextBox2.Text.Trim
                olecmd.ExecuteNonQuery()
            Else
                MsgBox("两次密码输入不一致!")
            End If
        Else
            MsgBox("原密码不正确!")
        End If
        olecon.Close()
    End Sub

运行后,提示至少有一个参数没有被指定值  好像是
olecmd.CommandText = "update info set 密码=" & TextBox2.Text.Trim
没有给值,还是我写法错误呀

fairy4 发表于 2007-12-15 15:34

olecmd.CommandText = "update info set 密码='" & TextBox2.Text.Trim"'"
試試看

hezhifang 发表于 2007-12-15 15:39

不行呀fairy4 怎么sql语言写法这么麻烦呀

hezhifang 发表于 2007-12-15 15:43

谢谢  fairy4我知道怎么写了

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

fairy4 发表于 2007-12-15 16:25

我少打了個&,汗!!

bygg 发表于 2007-12-16 13:53

[quote]原帖由 [bold][underline]hezhifang[/underline][/bold] 于 2007-12-15 15:43 发表 [url=http://bbs.bc-cn.net/redirect.php?goto=findpost&pid=1149229&ptid=192609][img]http://bbs.bc-cn.net/images/common/back.gif[/img][/url]
谢谢  fairy4我知道怎么写了

olecmd.CommandText = "update info set 密码='" & TextBox2.Text.Trim & "'" [/quote]
你这样不是把数据库中这张表中的所有密码都改了??

fairy4 发表于 2007-12-17 08:28

樓主的是批量更改密碼!呵呵!
[em09] 有空的時候加個條件就是了![em09] [em09] [em09]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.