vb.net中的MsgBoxStyle.YesNo [英] MsgBoxStyle.YesNo in vb.net

查看:415
本文介绍了vb.net中的MsgBoxStyle.YesNo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想使用一个按钮更新数据库,但是会出现消息框,要求您进行确认.这是我的代码.我不知道是什么错误.当我按下否"按钮时,它仍然会更新数据库.谢谢

hi all,

i want to update a database using a button but the message box will appear to ask for confirmation. here are my code. i do not know what the mistake. when i press the NO button, it still update the database. thank you

MsgBox("Are you sure want to update?", MsgBoxStyle.YesNo, "Pengesahan")
        If MsgBoxResult.Yes Then
            Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DatabaseKTF.mdf;Integrated Security=True;User Instance=True")
            Dim strupdate As String
            Dim cmd As SqlCommand
            strupdate = "UPDATE Bilik set StatusBilik= @StatusBilik, StudIcNo=NULL where Blok='" & ddlBlok.SelectedValue & "' AND Aras= '" & ddlAras.SelectedValue & "' AND Jenis= '" & ddlJenis.SelectedValue & "'"
            cmd = New SqlCommand(strupdate, con)
            con.Open()
            cmd.Parameters.AddWithValue("@StatusBilik", lblAvailable.Text)
            cmd.ExecuteNonQuery()
            cmd.Parameters.Clear()
            con.Close()
        ElseIf MsgBoxResult.No Then
            Response.Redirect("~/Admin/KemaskiniBilik.aspx")
        End If

推荐答案

不,不.您取回MessageBox并与MessageBoxResult.Yes进行比较:
No, no. You take return of MessageBox and compare with MessageBoxResult.Yes:
If MessageBox("...", ...) = MessageBoxResut.Yes Then ...


--SA


--SA


这篇关于vb.net中的MsgBoxStyle.YesNo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆