未处理的“System.StackOverflowException”类型的异常出现在 System.Windows.Forms.dll 中。

ll821121 2009-03-09 08:53:30
程序如下:
public partial class Form1 : Form
{
private SqlCeConnection cn;
private SqlCeCommand cmd;
int i = 0;
public Form1()
{
InitializeComponent();
this.timer1.Interval = 10000;
timer1.Enabled = true;
}

private void timer1_Tick(object sender, EventArgs e)
{
SqlCeConnection cn = null;

try
{
cn = new SqlCeConnection();
cn.ConnectionString = @"Data Source =F:\database\database\sqlmobile.sdf";
cn.Open();
SqlCeCommand cmd = cn.CreateCommand();
cmd.CommandText = "学生信息表";
cmd.CommandType = CommandType.TableDirect;
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "学生信息表");
i++;
Console.WriteLine("{0}",i);

while (i<3)
{
DataRow dr = ds.Tables["学生信息表"].Rows[2];
this.textBox1.Text = dr[0].ToString();
this.textBox2.Text = dr[1].ToString();
this.textBox3.Text = dr[2].ToString();

}


}
catch (SqlCeException sqlex)
{
foreach (SqlCeError sqlerror in sqlex.Errors)
{ MessageBox.Show(sqlerror.Message); }
}
catch (Exception ex) { MessageBox.Show(ex.Message); }//此处出错:未处理的“System.StackOverflowException”类型的异常出现在 System.Windows.Forms.dll 中。
finally { if (cn.State!= ConnectionState.Closed) { cn.Close(); } }


}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“sqlmobileDataSet.学生信息表”中。您可以根据需要移动或移除它。
this.学生信息表TableAdapter.Fill(this.sqlmobileDataSet.学生信息表);

}
}
     平台:vs.net 2005、sql ce数据库
...全文
441 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackyfedere 2009-08-09
  • 打赏
  • 举报
回复
不要在构造函数中尝试做赋值以外的操作

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧