有关调用实时 (JIT) 调试而不是此对话框的详细信息,
请参阅此消息的结尾。************** 异常文本 **************
System.InvalidOperationException: 在没有任何数据时进行无效的读取尝试。
   at System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i)
   at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)
   at System.Data.SqlClient.SqlDataReader.get_Item(String name)
   at WindowsApplication6.Form1.button1_Click(Object sender, EventArgs e) in e:\my documents\visual studio projects\windowsapplication6\form1.cs:line 252
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3705.0
    基本代码:file:///c:/windows/microsoft.net/framework/v1.0.3705/mscorlib.dll
----------------------------------------
WindowsApplication6
    程序集版本:1.0.1785.20638
    Win32 版本:1.0.1785.20638
    基本代码:file:///e:/My%20Documents/Visual%20Studio%20Projects/WindowsApplication6/bin/Debug/WindowsApplication6.exe
----------------------------------------
System.Windows.Forms
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3705.0
    基本代码:file:///c:/windows/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3705.0
    基本代码:file:///c:/windows/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3705.0
    基本代码:file:///c:/windows/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3705.0
    基本代码:file:///c:/windows/assembly/gac/system.xml/1.0.3300.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Data
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3705.0
    基本代码:file:///c:/windows/assembly/gac/system.data/1.0.3300.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.EnterpriseServices
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3705.0
    基本代码:file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.3300.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
----------------------------------------
mscorlib.resources
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3300.0
    基本代码:file:///c:/windows/assembly/gac/mscorlib.resources/1.0.3300.0_zh-chs_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
System.Data.resources
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3300.0
    基本代码:file:///c:/windows/assembly/gac/system.data.resources/1.0.3300.0_zh-chs_b77a5c561934e089/system.data.resources.dll
----------------------------------------
System.Windows.Forms.resources
    程序集版本:1.0.3300.0
    Win32 版本:1.0.3300.0
    基本代码:file:///c:/windows/assembly/gac/system.windows.forms.resources/1.0.3300.0_zh-chs_b77a5c561934e089/system.windows.forms.resources.dll
----------------------------------------************** JIT 调试 **************
若要启用实时 (JIT) 调试,此
应用程序或计算机的配置文件 (machine.config) 的 
 system.windows.forms 节中必须设置 jitDebugging 值。
编译应用程序时还必须启用
调试。例如:<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>启用 JIT 调试后,任何未处理的异常
将被发送到此计算机上注册的 JIT 调试器,
而不是由此对话框处理。

解决方案 »

  1.   

    SqlDataReader默认位置是在第一条记录的前面,所以在读取记录前必须调用Read来开始访问数据你WinFrom代码里没有见到调用read的代码
      

  2.   

    有呀 
    SqlDataReader thisReader = thisCommand.ExecuteReader();
      

  3.   

    加上这个
    thisReader.Read()
      

  4.   

    if(this.Reader.Read())
    {
       textBox2.Text=Convert.ToString(thisReader["Connect"]);
       textBox3.Text=Convert.ToString(thisReader["Expiredtime"]);
       textBox4.Text=Convert.ToString(thisReader["UID"]);
     
    }
      

  5.   

    if(thisReader.Read())
    {
       if(!thisReader.IsDBNull(2))
       {
          textBox2.Text = thisReader.GetString(2);
       }
      ......
    }