file operation

sj1187534

Well-known member
Joined
Jun 10, 2003
Messages
108
Location
Dallas, Houston, etc.etc.
Hi...can anyone tell me what is wrong with this function to write data to a file from a datareader??

Code:
Function WriteCSV(ByRef reader As SqlDataReader)
        Dim strFile As String
        strFile = "D:\CSVData.csv"
        Dim writer As New StreamWriter(strFile, True)
        While reader.Read
            writer.WriteLine(reader(0))
            writer.WriteLine(reader(0))
        End While
        fs.Close()
    End Function
I am calling this function from here:

Code:
Dim command As SqlCommand = New SqlCommand("Select * FROM Products", DBConnection)
Dim reader As SqlDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
WriteCSV(reader)
dgrOut.DataSource = reader
dgrOut.DataBind()
For some reason, the datagrid operations after the WriteCSV()function is called are not executing...

Thanks,
SJ
[edit]Please use
Code:
 tags [/ vb][/COLOR] [/edit]
 
Last edited by a moderator:
Back
Top