sj1187534
Well-known member
Hi...can anyone tell me what is wrong with this function to write data to a file from a datareader??
I am calling this function from here:
For some reason, the datagrid operations after the WriteCSV()function is called are not executing...
Thanks,
SJ
[edit]Please use
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
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()
Thanks,
SJ
[edit]Please use
Code:
tags [/ vb][/COLOR] [/edit]
Last edited by a moderator: