DataTable tempTable = new DataTable();
tempTable = dt.Clone();
String query = "";
query = "Time >= '" + StartDateTime + "' AND Time < = '" + EndDateTime + "'";
DataRow[] dr = dt.Select(query);
if (dr.Length > 0)
{
foreach (DataRow row in dr)
{
tempTable.ImportRow(row);
}
fpSpread1.ActiveSheet.DataSource = tempTable;
}
————————————————————————————————————–
Hello,
I have a spread sheet that initially gets populated with a data source.
I need to execute a query on that data source and populate the result into that spread sheet again. The piece of code above shows that. (I can not share my complete project due to some official reasons).
This works well but sometimes the red cross appears on the spreadsheet, giving the exception attached here with.
Following shows the details of the exception.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Exception: Exception handled in FpSpread.WndProc —> System.Exception: Exception handled in FpSpread.OnPaint() —> System.NullReferenceException: Object reference not set to an instance of an object.
at FarPoint.Win.Spread.SpreadView.e(Graphics A_0)
at FarPoint.Win.Spread.SpreadView.g(Graphics A_0)
at FarPoint.Win.Spread.FpSpread.OnPaint(PaintEventArgs e)
— End of inner exception stack trace —
at FarPoint.Win.Spread.FpSpread.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
— End of inner exception stack trace —
at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
—————————————-
ADEA
Assembly Version: 4.0.0.0
Win32 Version: 4.0.0.0
CodeBase: file:///E:/ADEA/Code/ADEA_Version3.5_Kamra/Code/ADEA/ADEA.exe
—————————————-
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
—————————————-
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
—————————————-
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
—————————————-
ServicesFramework
Assembly Version: 2.0.0.0
Win32 Version: 2.0.0.0
CodeBase: file:///E:/ADEA/Code/ADEA_Version3.5_Kamra/Code/ADEA/ServicesFramework.DLL
—————————————-
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
—————————————-
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
—————————————-
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
—————————————-
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
—————————————-
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
—————————————-
FarPoint.Win.Spread
Assembly Version: 6.0.2005.2008
Win32 Version: 6.0.2005.2008
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/FarPoint.Win.Spread/6.0.2005.2008__327c3516b1b18457/FarPoint.Win.Spread.dll
—————————————-
FarPoint.Win
Assembly Version: 6.0.2005.2008
Win32 Version: 6.0.2005.2008
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/FarPoint.Win/6.0.2005.2008__327c3516b1b18457/FarPoint.Win.dll
—————————————-
FarPoint.PluginCalendar.WinForms
Assembly Version: 6.0.2005.2008
Win32 Version: 6.0.2005.2008
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/FarPoint.PluginCalendar.WinForms/6.0.2005.2008__327c3516b1b18457/FarPoint.PluginCalendar.WinForms.dll
—————————————-
FarPoint.CalcEngine
Assembly Version: 6.0.2005.2008
Win32 Version: 6.0.2005.2008
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/FarPoint.CalcEngine/6.0.2005.2008__327c3516b1b18457/FarPoint.CalcEngine.dll
—————————————-
FarPoint.Win.Chart
Assembly Version: 6.0.2005.2008
Win32 Version: 6.0.2005.2008
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/FarPoint.Win.Chart/6.0.2005.2008__327c3516b1b18457/FarPoint.Win.Chart.dll
—————————————-
FarPoint.Excel
Assembly Version: 6.0.2005.2008
Win32 Version: 6.0.2005.2008
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/FarPoint.Excel/6.0.2005.2008__327c3516b1b18457/FarPoint.Excel.dll
—————————————-
NationalInstruments.UI
Assembly Version: 13.0.40.242
Win32 Version: 13.0.40.242
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/NationalInstruments.UI/v4.0_13.0.40.242__dc6ad606294fc298/NationalInstruments.UI.dll
—————————————-
NationalInstruments.UI.WindowsForms
Assembly Version: 13.0.40.242
Win32 Version: 13.0.40.242
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/NationalInstruments.UI.WindowsForms/v4.0_13.0.40.242__dc6ad606294fc298/NationalInstruments.UI.WindowsForms.dll
—————————————-
NationalInstruments.Common
Assembly Version: 13.0.40.188
Win32 Version: 13.0.40.188
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/NationalInstruments.Common/v4.0_13.0.40.188__dc6ad606294fc298/NationalInstruments.Common.dll
—————————————-
System.Web
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Web/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.dll
—————————————-
NationalInstruments.Common.Native
Assembly Version: 13.0.40.188
Win32 Version: 13.0.40.188
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/NationalInstruments.Common.Native/v4.0_13.0.40.188__dc6ad606294fc298/NationalInstruments.Common.Native.dll
—————————————-
System.Design
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Design/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Design.dll
—————————————-
Accessibility
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
—————————————-
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Please guide me is the above code has some problem or is there any better way
to populate the existing spreadsheet with the records of the query results.
Waiting for your reply.
Thankyou and Regards,
Naureen