嗨我正在使用下面的微软企业库是代码
对于数据集
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
即使当我在 sql 中运行相同的查询时有行时,我的行数也为 0 ......有什么建议吗?