Results 1 to 3 of 3

Thread: Export Dataset Issue

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    Export Dataset Issue

    I'm using the below code to export my dataset in a CSV format. Everything works on our test server but when we push to the internet i get the following error when trying to export.

    Error message in IE:
    Internet Explorer cannot download <page name> from <site name>
    Internet Explorer was not able to open this internet site. The requested site is either unavailable or cannot be found. Please try again later.

    Code:
            Dim ds As DataSet = New DataSet
            Dim cn As SqlConnection
            Dim cmd As SqlCommand
            Dim filename As String
            Dim dr As SqlDataReader
            Dim i As Integer
            Dim sb As System.Text.StringBuilder
    
            cn = New SqlConnection(ConfigurationSettings.AppSettings("MedicareDBconn"))
            filename = "MemberList.csv"
    
            cmd = New SqlCommand("SELECT m.FirstName, m.LastName, m.Gender, A.DateActivity, ad.Street1, ad.Street2, ad.City, ad.State, ad.Zip, p.PhoneNumber " _
                  & " FROM dbo.MemberNote MN INNER JOIN " _
                  & " dbo.Member m INNER JOIN " _
                  & " dbo.ContactInfoAddress cia ON m.ContactInfoID = cia.ContactInfoID INNER JOIN " _
                  & " dbo.Address ad ON ad.AddressID = cia.AddressId ON MN.MemberID = m.MemberID INNER JOIN " _
                  & " dbo.Note N ON MN.NoteID = N.NoteID INNER JOIN " _
                  & " dbo.Activity A ON m.MemberID = A.MemberID LEFT OUTER JOIN " _
                  & " dbo.Phone p INNER JOIN " _
                  & " dbo.ContactInfoPhone cip ON p.PhoneID = cip.PhoneID ON m.ContactInfoID = cip.ContactInfoID " _
                  & " WHERE     (N.DispositionTypeID IN ('148', '149', '150', '151')) AND (A.UserID = 37) AND (m.DoNotCall IS NULL) " _
                  & " GROUP BY m.FirstName, m.LastName, m.Gender, A.DateActivity, ad.Street1, ad.Street2, ad.City, ad.State, ad.Zip, p.PhoneNumber", cn)
    
    
            cmd.Connection.Open()
    
            dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
            sb = New System.Text.StringBuilder
    
            'For field Names 
    
            For i = 0 To dr.FieldCount - 1
    
                If i < (dr.FieldCount - 1) Then
    
                    sb.Append(Chr(34) & dr.GetName(i) & Chr(34) & ",")
    
                Else
    
                    sb.Append(Chr(34) & dr.GetName(i) & Chr(34) & vbCrLf)
    
                End If
    
            Next
    
            'For field Values 
    
            While dr.Read()
    
                For i = 0 To dr.FieldCount - 1
    
                    If i < (dr.FieldCount - 1) Then
    
                        sb.Append(Chr(34) & dr.GetValue(i).ToString & Chr(34) & ",")
    
                    Else
    
                        sb.Append(Chr(34) & dr.GetValue(i).ToString & Chr(34) & vbCrLf)
    
                    End If
    
                Next
    
            End While
    
            dr.Close()
            cn.Close()
    
            Response.Clear()
            Response.ContentType = "application/octet-stream"
            Response.AddHeader("content-disposition", "attachment; filename=""" & filename & """")
    
            'Write the file directly to the HTTP output stream. 
    
            Response.Write(sb.ToString)
            Response.End()

  2. #2
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: Export Dataset Issue

    It sounds to me like IIS has not been set up corectly.

    I know this is going to sound silly but have you created a virtual folder and not just created a folder in WWWroot or whatever else is your root ?

    Parksie

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Export Dataset Issue

    Create a virtual directory in IIS.

    Give it all the permissions in the wizard.

    Make sure you've copied over all the files from the original folder. (We can get to removing the useless ones later)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width