0
Imports System.Data.OleDb

Namespace wbdsproject

    Partial Class frmUserPrvMsg
        Inherits System.Web.UI.Page

        Dim topicDb As OleDbConnection
        Dim topicCmd As OleDbCommand
        Dim topicReader As OleDbDataReader
        Dim topicId As Integer
        Dim AuthorName, Username As String

    #Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub


        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

    #End Region

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
            'Put user code to initialize the page here
            Dim uid As Int16
            topicId = Request.QueryString("topicId")
            topicDb = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\discussion\SampleForum.mdb")
            topicDb.Open()
            If Session("loginuser") = "" Then
                Response.Redirect("frmlogin.aspx")
            End If
            Username = Session("loginuser")
            topicCmd = New OleDbCommand("select uid from tbllog where uname='" & Username & "'", topicDb)
            uid = topicCmd.ExecuteScalar
            topicCmd = New OleDbCommand("Select uname,pMsgDate,pMsgSubject,pMsgDetail from tblprivatemessage, tbllog where tblprivatemessage.pMsgTo=" & uid & " and tbllog.uid=tblprivatemessage.pMsgFrom", topicDb)
            topicReader = topicCmd.ExecuteReader
            DataGrid2.DataSource = topicReader

            DataGrid2.DataBind()
            topicReader.Close()
        End Sub

        Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        End Sub

        Private Sub btninbox_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btninbox.Click
            Response.Redirect("frmUserPrvMsg.aspx")
        End Sub

        Private Sub btnOutBox_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnOutBox.Click
            Response.Redirect("OutBox.aspx")
        End Sub  
   End Class
End Namespace

beginner in .net ,simply i run cant understand unknoen problem.any soutions

Chris Dunaway
  • 10,974
  • 4
  • 36
  • 48
peter
  • 43
  • 1
  • 7

1 Answers1

1

Your command

select uid from tbllog where uname='UserName'

is returning DBNull.

This topic should be of some help : DBNull check for Execute Scalar

Community
  • 1
  • 1
Insane
  • 654
  • 10
  • 18