asp.net给我行计数为零时出错
您好,我正在使用microsoft企业库,下面是代码 对于数据集asp.net给我行计数为零时出错,asp.net,sql-server,enterprise-library,Asp.net,Sql Server,Enterprise Library,您好,我正在使用microsoft企业库,下面是代码 对于数据集 Public Function FetchUserValue(ByVal uemail As String) As DataSet Dim ds As New DataSet() Try Dim query As String = String.Format("select * from v_userdetails where uemail='{0}' ", uemail) Dim
Public Function FetchUserValue(ByVal uemail As String) As DataSet
Dim ds As New DataSet()
Try
Dim query As String = String.Format("select * from v_userdetails where uemail='{0}' ", uemail)
Dim cmd As New SqlCommand(query, con)
Dim adapter As New SqlDataAdapter(cmd)
adapter.Fill(ds)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return ds
End Function
代码隐藏函数
Dim obj As New barter
Dim sb As New StringBuilder()
Dim user As String = CookieUtil.GetEncryptedCookieValue("MERE1000CR").ToString
Try
Dim dtProducts As DataTable = obj.FetchUserValue(user).Tables(0)
Dim rp As System.Data.DataRow
If dtProducts.Rows.Count > 0 Then
For rowIndex As Integer = 0 To dtProducts.Rows.Count - 1
rp = dtProducts.Rows(rowIndex)
Try
If Convert.ToInt32(rp(0)) = 1 Then
sb.Append(" <div>Welcome " & Convert.ToInt32(rp(2)).ToString & "</div>" & _
"<div class='dps'><img src='" & Convert.ToInt32(rp(9)).ToString & "' width='100px'/></div><div class='inf'></div></div style='clear:both'></div>")
ElseIf Convert.ToInt32(rp(0)) = 0 Then
Response.Redirect("Activation.aspx")
ElseIf Convert.ToInt32(rp(0)) = 2 Then
Response.Redirect("Blocked.aspx")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Next
profiler.InnerHtml = sb.ToString
Else
MsgBox("something wrong...")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim obj作为新易货
使某人成为新的架线工
Dim user As String=CookieUtil.GetEncryptedCookieValue(“MERE1000CR”).ToString
尝试
Dim dtProducts As DataTable=obj.FETCHTUSERVALUE(用户).Tables(0)
将rp尺寸标注为System.Data.DataRow
如果dtProducts.Rows.Count>0,则
对于dtProducts.Rows.Count-1,行索引为整数=0
rp=dtProducts.Rows(行索引)
尝试
如果Convert.ToInt32(rp(0))=1,则
sb.Append(“欢迎”和Convert.ToInt32(rp(2)).ToString&“_
"")
ElseIf Convert.ToInt32(rp(0))=0然后
Response.Redirect(“Activation.aspx”)
ElseIf Convert.ToInt32(rp(0))=2然后
Response.Redirect(“Blocked.aspx”)
如果结束
特例
MsgBox(例如消息)
结束尝试
下一个
profiler.InnerHtml=sb.ToString
其他的
MsgBox(“出了什么问题…”)
如果结束
特例
MsgBox(例如消息)
结束尝试
当我在sql中运行同一查询时,即使有行,我也会得到行数0。。。。有什么建议吗?你的对象不应该被声明为
Dim obj as New barter()
?没有任何barter是不同的类文件,即使我放了barter(),也没有任何区别…嗯,您是否已检查从cookie中检索的用户变量的值是否存在于数据库的表中。是的,即使我更改查询并插入值而不是遍历变量,它仍然为我提供0行计数器错误已解决我刚从项目中删除了dataset.xsd文件。