Link to home
Start Free TrialLog in
Avatar of mahalakshmi_s
mahalakshmi_s

asked on

write HTML file from VB.NET

Hi ,

I have my VB.NET writing the output in form of CSV file. Below is the code. It works fine and it gives me 20 records. Now I have to write the same content in form of HTML file with one thing extra. All the 20 rows will have one column "RecordIDFor1880" for which I have to give link. If user clicks it, it will open up some other page for which I know the path.
How can I achieve it?

Maha


Public Sub GenerateCSV()

        Try
            Dim OutputFileMSA As String = Application.StartupPath & "\CSVFiles\" & FirstLastName & ".csv"
            Dim myFileStream As New System.IO.FileStream(OutputFileMSA, _
           FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)
            'Create the stream writer
            Dim OutputFNMSA As New System.IO.StreamWriter(myFileStream)

            OutputFNMSA.WriteLine("Counter" & "," & "CountFromBlockedSet" & "," & "RecordIDFor1880" & "," & "FIRSTNAME" & "," & "LASTNAME" & "," & "Total Score")
            Dim connstr = "server=CSDAMAP1;uid=namematch;pwd=namematch;database=NameSearch;"
            Dim sqlConn4 As New SqlConnection(connstr)
            sqlConn4.Open()
            Dim rsSort_sqlcomm As New SqlCommand("SELECT * from ScoreTableNoQuotes order by TotalScore Desc", sqlConn4)
            Dim rsSortDR As SqlDataReader = rsSort_sqlcomm.ExecuteReader()
            Dim SortRecCount As Integer
            SortRecCount = 1

            While rsSortDR.Read()
                If SortRecCount <= 20 Then                  
                    OutputFNMSA.WriteLine(SortRecCount & "," & rsSortDR("CountFromBlockedSet") & "," & rsSortDR("RecordIDFor1880") & "," & rsSortDR("frstname") & "," & rsSortDR("lastname") & "," & rsSortDR("totalscore") & "," )
                    SortRecCount = SortRecCount + 1
                Else
                    Exit While
                End If
            End While

            OutputFNMSA.Close()
            OutputFNMSA = Nothing
            rsSortDR.Close()
            rsSortDR = Nothing
            sqlConn4.Close()
            sqlConn4 = Nothing
        Catch ex As Exception          
            MessageBox.Show(Err.Description, vbCritical, "JaroWeight")
        End Try
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of AerosSaga
AerosSaga

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial