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
VB
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
                Response.Redirect("Login.aspx")
            Else
                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"
                Else
                    sDelimiter = Page.Request.Item("delimiter").ToString.ToLower
                End If

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

                If Page.Request.Item("dateformat") Is Nothing Then
                    sDateFormat = Format(CDate(Date.Now.ToShortDateString), "yyyyMMdd")
                Else
                    sDateFormat = Page.Request.Item("dateformat").ToString
                End If
Posted
Updated 25-Jun-13 21:16pm
v2
Comments
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()

Try
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 = ""
Else
strPostDate = dPostDate.ToShortDateString
End If

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

Response.Buffer = True
Response.AddHeader("Content-Disposition", "attachment;filename=WIFI_Registrants_" & sDateFormat & ".txt")
Response.ContentType = "text/plain"
Response.Write(str.ToString())
Catch ex As Exception
Response.Redirect("ErrorPage.aspx?id=" & pFun.Set_ErrorMessage(ex.Message, ex.ToString, Request.RawUrl.Trim).ToString, False)
End Try
Else
CloseWindow()
End If
End If
Else
Response.Redirect("Login.aspx")
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
   
no..im 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