sj1187534 Posted June 20, 2003 Posted June 20, 2003 (edited) Hi...can anyone tell me what is wrong with this function to write data to a file from a datareader?? 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: 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 tags [/ vb][/color] [/edit] Edited June 20, 2003 by Robby Quote
Moderators Robby Posted June 20, 2003 Moderators Posted June 20, 2003 Does it work if you skip this line WriteCSV(reader)? Quote Visit...Bassic Software
sj1187534 Posted June 21, 2003 Author Posted June 21, 2003 Yes....it works when I dont call the WriteCSV function .. SJ Quote
Moderators Robby Posted June 21, 2003 Moderators Posted June 21, 2003 send it byVal instead of byRef, it should work Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.