Click here to Skip to main content
15,306,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone i have a code here that convert database in .csv /. txt file where i having an error by using Dim pFun As New PageFunctions as i use Imports System.Windows.Navigation still there is system error behind.. please help or share any ideas to replace this error thanks

Option Explicit On
Imports System.Configuration
Imports System.Data
Imports System.Net.Mail
Imports System.Runtime.InteropServices.Marshal
Imports System.IO
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Text
Imports System.Windows.Navigation

Partial Class GetTextFile
    Inherits System.Web.UI.Page

    Dim pFun As New PageFunctions

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Not pFun.IsUserLoggedIn Then
                Dim dt As New Data.DataTable

                Dim strViewDate As String = String.Empty
                Dim dVDate As DateTime = Now
                Dim strAcctNo As String = String.Empty
                Dim strTelNo As String = String.Empty
                Dim strEmail As String = String.Empty
                Dim strPostDate As String = String.Empty
                Dim dPostDate As DateTime = Now
                Dim strRef As String = String.Empty

                Dim sDelimiter As String = ""
                Dim delimiter As String = ""

                Dim sDateFormat As String = ""

                If Page.Request.Item("delimiter") Is Nothing Then
                    sDelimiter = "tab"
                    sDelimiter = Page.Request.Item("delimiter").ToString.ToLower
                End If

                If sDelimiter = "comma" Then
                    delimiter = ","
                ElseIf sDelimiter = "tab" Then
                    delimiter = vbTab
                    delimiter = vbTab
                End If

                If Page.Request.Item("dateformat") Is Nothing Then
                    sDateFormat = Format(CDate(Date.Now.ToShortDateString), "yyyyMMdd")
                    sDateFormat = Page.Request.Item("dateformat").ToString
                End If
Updated 25-Jun-13 21:16pm
Member 10033107 26-Jun-13 3:04am
dt = CType(Session("dt"), Data.DataTable)

If Not IsNothing(dt) AndAlso dt.Rows.Count > 0 Then
Dim str As New StringBuilder()

str.Append("Registration Date" & delimiter & "Account No." & delimiter & "Telephone No." & delimiter & "Email Address" & delimiter & "Post Date" & vbCrLf)

For Each oRow As Data.DataRow In dt.Rows
dVDate = oRow("DteStp").ToString
strViewDate = dVDate.ToShortDateString

strAcctNo = oRow("AccountNo").ToString.Trim
strTelNo = oRow("AreaTele").ToString.Trim
strEmail = oRow("EmailAddress").ToString.Trim

dPostDate = oRow("ProcessDate")
If dPostDate <= "01/01/2000" Then
strPostDate = ""
strPostDate = dPostDate.ToShortDateString
End If

str.Append(strViewDate & delimiter & strAcctNo & delimiter & strTelNo & delimiter & strEmail & delimiter & strPostDate & vbCrLf)

Response.Buffer = True
Response.AddHeader("Content-Disposition", "attachment;filename=WIFI_Registrants_" & sDateFormat & ".txt")
Response.ContentType = "text/plain"
Catch ex As Exception
Response.Redirect("ErrorPage.aspx?id=" & pFun.Set_ErrorMessage(ex.Message, ex.ToString, Request.RawUrl.Trim).ToString, False)
End Try
End If
End If
End If
End Sub

Private Function GetConfig(ByVal key As String) As String
GetConfig = System.Configuration.ConfigurationManager.AppSettings(key).ToString
End Function

Private Sub CloseWindow()
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "xCloser", "window.close();", True)
End Sub

Private Sub MessageAndCloseWindow(ByVal msg As String)
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "xCloser", "alert('" & msg & "'); window.close();", True)
End Sub

End Class
Richard MacCutchan 26-Jun-13 3:07am
What error, where does it occur? Also, please format your code properly by putting <pre> tags around it.
Member 10033107 26-Jun-13 3:09am
hi richard.. the error called in my program like this Type 'PageFunction' is not defined
Mahesh Bailwal 26-Jun-13 3:53am
Are you creating Sliverlight application?
Richard MacCutchan 26-Jun-13 5:41am
Then you need to define it.
Member 10033107 26-Jun-13 4:01am just using microsoft visual studio 2010

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900