Showing posts with label spreadsheet. Show all posts
Showing posts with label spreadsheet. Show all posts

Wednesday, March 21, 2012

DataRowState

After loading an Excel spreadsheet into a DataTable, how do I programatically change the DataRowState from .UnChanged to .Added?

Thanks,

DJ

Wrong Forum. Better ask on the .NET forums.

But I remember it is only possible if you use .NET 2.0; In .NET 1.1 you can't able to set it explictly..

Monday, March 19, 2012

DataReader Output skipping first line

I am using the following code to query a DB and output an Excel Spreadsheet. For some reason, the first line is always missing.

Any help would be greatly appreciated.


============================================

1reader = cmd.ExecuteReader()2If Not reader.Read()Then3 Return False4Else5 For i = 0To reader.FieldCount - 16 strLine += reader.GetName(i).ToString & Chr(9)7Next8 objStreamWriter.WriteLine(strLine)9 strLine =""10With reader11While .Read12For x = 0To .FieldCount - 113 strLine = strLine & reader.GetValue(x) & Chr(9)14Next15 objStreamWriter.WriteLine(strLine)16 strLine =""17End While18 End With19End If

line 2 of you code is wasting the first row of data by performing a reader.Read that you ignore.

change line 2 to:

If Not reader.HasRows()Then
|||

Perfect!

Thank you!!!!