// 给出两段代码 CS程序 方法1成功,方法2失败
1。直接在窗体下写成功
SqlCeConnection cn= new SqlCeConnection(@"Data Source =\My Documents\gatheringService.sdf");
if (cn.State==ConnectionState.Closed)
cn.Open();
string sSQL="select customerId ,customerName from customerInfo ";
SqlCeCommand cmdSelect=new SqlCeCommand(sSQL,cn);
SqlCeDataReader dtr=cmdSelect.ExecuteReader(CommandBehavior.Default);
this.comboBox1.Items.Clear();
//this.comboBox1.DataSource = dtr;
//this.comboBox1.DisplayMember="customerName";
//this.comboBox1.ValueMember ="customerId";
while (dtr.Read())
{
this.comboBox1.Items.Add(dtr[0].ToString());
}
cn.Close()
/////////////////////////////////////////////
2。调用方法
public static SqlCeDataReader ExecSql(string strSql)
{
SqlCeDataReader dtr= null; 
SqlCeConnection cn= new SqlCeConnection(@"Data Source =\My Documents\gatheringService.sdf");
try
{

if (cn.State==ConnectionState.Closed)
cn.Open();
//string sSQL="select customerId ,customerName from customerInfo ";
SqlCeCommand cmdSelect=new SqlCeCommand(strSql,cn);
dtr=cmdSelect.ExecuteReader(CommandBehavior.Default);
}
catch(SqlCeException ex)
{
throw ex; }
finally
{
cn.Close();
}
return  dtr;
}
string sSQL="select customerId ,customerName from customerInfo ";
SqlCeDataReader dtr = database.ExecSql(sSQL);
this.comboBox1.Items.Clear();
//this.comboBox1.DataSource = dtr;
//this.comboBox1.DisplayMember="customerName";
//this.comboBox1.ValueMember ="customerId";
while (dtr.Read())
{
this.comboBox1.Items.Add(dtr[0].ToString());
}
错误信息  未处理的“System.InvalidOperationException”类型的异常出现在 System.Data.SqlServerCe.dll 中。其他信息: 无法找到资源程序集备注:开发环境VS2003 + SQL SERVER CE2。0 PDA HP1950 WIN MOBILE 5。0
什么原因了