- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用以下代码来填充数据集
public static DataSet GetDataSetBySP(string spName)
{
try
{
using (SqlConnection conn = new SqlConnection(ConnString))
{
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = spName;
cmd.CommandTimeout = 60;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
conn.Close();
return ds;
}
}
catch
{
return null;
}
}
我第一次调用该函数时,我只得到了第一个充满数据的表,其他表看起来像这样
Data Visualizer 中的错误类似于
DataSet Visualizer
Unhandled exception has occurred in a component in your application.If you click Continue,the application will ignore this error and attempt to continue.
Object referance not set to an instance of an object
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at EnhancedDataSetVisualizer.VisualizerCommunicator.GetTableCellValue(Int32 rowIndex, Int32 colIndex)
at EnhancedDataSetVisualizer.DataSetForm.dataGridView_CellValueNeeded(Object sender, DataGridViewCellValueEventArgs e)
at System.Windows.Forms.DataGridView.OnCellValueNeeded(DataGridViewCellValueEventArgs e)
at System.Windows.Forms.DataGridView.OnCellValueNeeded(Int32 columnIndex, Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.GetValue(Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.PaintWork(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.PaintCells(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow)
at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.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: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Microsoft.VisualStudio.CommonIDE
Assembly Version: 9.0.0.0
Win32 Version: 9.0.30729.1
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.CommonIDE/9.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.CommonIDE.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.VisualStudio.DebuggerVisualizers
Assembly Version: 9.0.0.0
Win32 Version: 9.0.30729.1
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.DebuggerVisualizers/9.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.DebuggerVisualizers.dll
----------------------------------------
Microsoft.VisualStudio.Debugger.DataSetVisualizer
Assembly Version: 9.0.0.0
Win32 Version: 9.0.30729.1
CodeBase: file:///C:/Program%20Files/Microsoft%20Visual%20Studio%209.0/Common7/Packages/Debugger/Visualizers/Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.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:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
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.
谁能告诉我为什么我会看到这个?但是第二次,当我刷新我的 aspx 页面时,我得到了所有包含正确数据的正确表格。
提前致谢
新编辑
大家好,感谢您的快速回复。但我没有在 catch 中收到任何错误。数据集完全成功填充,即使我得到正确的第一个表的数据,但我发现 2 个表的其余部分没有代码异常。
最新更新
另外我在另一个测试中发现,Dataset Visualizer 没有显示那个数据表节点。它包含记录/表格但仍然显示上述错误。可能是由于某些问题
最佳答案
您是否正在检查返回值是否不为空?您的函数中可能存在一些异常。我会重新制作 catch 部分以
catch
{
return new DataSet();
}
或者更好的是,我会创建一些错误事件来显示一些错误的消息框。
catch(Exception exc)
{
Error(exc);
return new DataSet();
}
关于c# - 对象引用未设置到数据集中对象的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9883872/
我想做一个系统,用户可以上传和下载文件。系统将具有一个集中的地形,但在很大程度上依赖于节点将相关数据通过中心节点传输给其他节点我不希望对等端保存整个文件,而是希望它们保存整个数据集的一个压缩的加密部分
我正在 Riverpod Auth 流程样板应用程序中工作。 我想对所有异步功能甚至登录和注销使用通用加载屏幕。目前,如果 Appstate 加载我显示加载屏幕,我有 AppState 提供程序。它可
我有一个 functions.php 文件,其中包括以下功能: function head() { global $brand, $brandName, $logo, $slogan, $si
我有下一个 html 代码 ... 我想选择随机的 div 数组来向它们添加一个事件类,因为我使用这个 jquery 代码 function randOrder() { return
多年来,我创建并调整了一组NAnt脚本以执行完整的项目构建。主脚本采用一个应用程序端点(例如,一个Web应用程序项目),并从源代码控制中对其进行完整的构建。脚本已预先配置了与构建输出位置,源代码控制地
我希望我的 jQuery 插件在 $(window) 选择上调用时表现不同。如何检查 window 是否在集合中?到目前为止我的尝试: >>> $(window) == $(window) false
考虑到我们有 let existingSet = $(); 如何通过 jQuery 将 newElements 添加到该集合中? existingSet = existingSet.add(newEl
我需要在 priority_queue 中保存一个整数集合。但是我需要能够删除这些整数中的一个,即使它不是我容器的第一个元素。我无法使用 std::priority_queue。我选择使用一个集合来根
对于我的网站,我一直在尝试集中所有内容以便在移动设备上显示: http://m.bachatdeals.com 我在移动设备上打开网站后,内容下方有很多空间,我必须捏住 zoon 才能阅读,如何删除下
我计划为我的剑道验证器制定一些自定义规则,并希望在所有验证器之间共享。在我的验证器代码中,我有: rules: { bothorblank: function (input) {
这是我的函数,用于测试两个点 x 和 y 在 MAX_ITERATION 255 之后是否在 mandelbrot 集合中。如果不在,它应该返回 0,如果在,则返回 1。 int isMandelbr
致力于从移动设备扩展到桌面设备的简单网站布局。一切都按预期工作,但由于某种原因,我的 float div 没有集中放置。我已经完成了正常工作,但这次不适合我?有什么想法吗? 这是我的 CSS: /*
我的“div”元素有一个相对宽度,它不是绝对的,所以我不能使用精确的数字来集中。一个不错的解决方案是使用“display: inline-block”: body { text-align:
目前我拥有的所有类都处理它们自己的导入。使用一个典型的例子: [ImportMany] private Lazy[] someOfMyInterfaces { get; set; } public M
我有一个类定义: class Question: title = "" answer = "" def __init__(self, title, answer):
我正在尝试将一个对象 Point2D 插入到一个 Point2D 集合中,但我做不到,似乎该集合适用于 int 和 char 但不适用于对象。 我需要帮助来了解如何将对象插入到集合中???假设我想按
我的应用上有一些弹出窗口,它是全屏的,代码如下: content.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
我们有一个多模块 Quarkus 项目,带有一个公共(public)库和多个应用程序。在通用的 lib 中,我们有各种缓存用于所有应用。 我们希望不必在每个应用程序的所有配置文件中配置保留和容量。 有
这个问题在这里已经有了答案: Nested facets in ggplot2 spanning groups (2 个回答) 去年关闭。 我在 ggplot 中创建了一个图表里面有两个变量 face
我无法集中v-radio-group。这是我得到的:
我是一名优秀的程序员,十分优秀!