gpt4 book ai didi

vb.net 数据集返回空值

转载 作者:行者123 更新时间:2023-12-02 17:50:37 25 4
gpt4 key购买 nike

您好,我已经用谷歌搜索了...已经 2 天了...这些空洞的东西真让我头疼! ...请有人告诉我我的代码有什么问题吗????

在这里:-

Public Sub checkemail()
sqlcheckemail = "select Email from WEBUSER where Email='" + TBEmail.Text + "'"
Dim dscheckemail As New DataSet
Dim sqlCnn As New SqlConnection
'Dim MYNULL As String
sqlCnn = New SqlConnection(connStr)
sqlCmd = New SqlCommand(sqlcheckemail, sqlCnn)
sqlCnn.Open()
da.SelectCommand = sqlCmd
da.Fill(dscheckemail)
'MYNULL = CheckDBNull(dscheckemail)
'If Not (dscheckemail.Tables.Count > 0) AndAlso (dscheckemail.Tables(0).Rows.Count > 0) Then
'If Not IsDBNull(dscheckemail) Then
'If Not (dscheckemail Is Nothing) Then
'If MYNULL = "NULL" Then
If Not dscheckemail Is Nothing Then
LabelGender.Text = "There is something"
'MsgBox("Unable to register because the E-mail address has already registered as a user, Please register using different Email address or contact administrator")
'Response.Redirect("~/Rnewuser.aspx")
Else
'MsgBox("u can register")
LabelGender.Text = "NULL"
End If

sqlCmd.Dispose()
sqlCnn.Close()
End Sub

如果你看到我评论过的那个是我已经在谷歌上测试过的那个……所以现在如果电子邮件地址存在于数据库中……一切都很好……但是如果它不存在代码应该处理不满足第一个 if 语句的那个​​……但现在我得到的结果是“有东西”,尽管数据库中不存在电子邮件……

请帮帮我!!!!我以前做过这个无效的事情..但很久以前我没有保存代码..现在我正在为我自己的网站做这件事..这让我很崩溃

最佳答案

dataset 不是nothing 所以进入if,你应该检查里面的datatable。

'is not nothing, but is safer this way
If Not dscheckemail Is Nothing Then

'Check there is a datatable inside the dataset and that it has rows
If dscheckemail.Tables(0) Is Nothing OrElse dscheckemail.Tables(0).Rows.Count = 0 Then
'is really empty
Else
'You have a dataTable with data.
End If

End If

关于vb.net 数据集返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8817644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com