访问数据库出现莫名其妙的异常错误:应用程序发生了未处理异常
HD杨 2004-05-13 03:07:53 源码如下:
Dim tConnStr, SQLStr As String
tConnStr = GetConnStr()
SQLStr = "SELECT ID,Title,Contents FROM v_News ORDER BY ID ASC"
Try
Dim tMyConn As New SqlConnection(tConnStr)
tMyConn.Open()
Dim tMyCmmd As New SqlCommand(SQLStr, tMyConn)
Dim tDa As New SqlDataAdapter
tDa.SelectCommand = tMyCmmd
Dim tDs As New DataSet("v_Config_Rpt_SetCreate")
tDa.Fill(tDs)
DataGrid1.DataSource = tDs.Tables(0).DefaultView
tDa.Dispose()
tMyCmmd.Dispose()
tMyConn.Close()
Catch ex As Exception
DataGrid1.CaptionText = ex.Message
End Try
上块代码每60秒刷新执行一次,10次偶然有一次错误,用try catch不能扑获.弹出提示:应用程序发生了未处理异常如果单击"继续",应用程序将忽略此错误并尝试继续.如果... "id 不属于表table" .请教高手是什么原因呢?
点"详细信息",出现下面的内容:
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参阅此消息的结尾。
************** 异常文本 **************
System.ArgumentException: 列“ID”不属于表 Table。
at System.Data.DataRow.CheckColumn(DataColumn column)
at System.Data.DataRow.get_Item(DataColumn column, DataRowVersion version)
at System.Data.DataRowView.GetColumnValue(DataColumn column)
at System.Data.DataColumnPropertyDescriptor.GetValue(Object component)
at System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(CurrencyManager source, Int32 rowNum)
at System.Windows.Forms.DataGridTextBoxColumn.Edit(CurrencyManager source, Int32 rowNum, Rectangle bounds, Boolean readOnly, String instantText, Boolean cellIsVisible)
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
.............jit调试