如何在空TextBox上获得错误(IF& Else已经有条件) [英] How to get error on empty TextBox (IF&Else already have conditions)

查看:36
本文介绍了如何在空TextBox上获得错误(IF& Else已经有条件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果"串行文本"框为空,我将如何获得错误。在我的代码序列中不能重复。

How I can get error if Serial Text box is blank. In my Code serial Cannot be repeated.

  cn.Open()

       尝试

            cmd.CommandText ="从监视器中选择COUNT(*)WHERE Serial ='" &安培; MSerialTxt.Text& "'"

            cmd.ExecuteNonQuery()
 cn.Open()
        Try
            cmd.CommandText = "Select COUNT(*) from Monitors WHERE Serial ='" & MSerialTxt.Text & "'"
            cmd.ExecuteNonQuery()

推荐答案

也许在代码之前添加这些行:

  
如果 MSerialTxt.Text.Trim.Length = 0
然后

  
    MSerialTxt.Select()

      MSerialTxt.Select()

      
MsgBox(
"请输入序列号")

      MsgBox("Please enter the Serial Number")

     ;   
返回

  
End
如果

 

顺便说一句,我认为不需要第一个
ExecuteNonQuery 。要提高质量,必须使用参数化查询。

By the way, I think that the first ExecuteNonQuery is not needed. And to increase the quality, you must use Parameterised Queries.


这篇关于如何在空TextBox上获得错误(IF& Else已经有条件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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