程序如下:private void BCLogon_Load(object sender, System.EventArgs e)
{
StreamReader sw = new StreamReader("conn.ini");
c.BCConn = sw.ReadLine();
sw.Close();SqlConnection connStr = new SqlConnection();
connStr.ConnectionString = c.BCConn;
strCom="";
strCom="select CompaniesCode,CompaniesName from BCCompanies";
SqlCommand cmd_company = new SqlCommand(strCom,connStr);
//
DataSet ds_company = new DataSet();
//
SqlDataAdapter da_company = new SqlDataAdapter(cmd_company);
//
connStr.Open();
da_company.Fill (ds_company,"Company");
connStr.Close(); } private void BCLogon_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
DialogResult result=MessageBox.Show("确认要离开BarCode系统吗?","BarCode系统提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);
if(result==DialogResult.Yes)
{
e.Cancel=false;
Application.Exit();
}
else
{
e.Cancel=true;
}
} private void Confirm_Click(object sender, System.EventArgs e)
{
if(this.CompanyNo.Text.ToString().Trim()=="")
{
MessageBox.Show("请选择您要登录的公司");
return;
} if(this.UserNo.Text.ToString().Trim()=="")
{
MessageBox.Show("请选择登录用户名");
return;
} SqlConnection connStr = new SqlConnection();
connStr.ConnectionString = c.BCConn; strCom="";
strCom="select * from BCUser where UserNo = '"+this.UserNo.Text.ToString().Trim()+"' and CompaniesNo = '"+this.CompanyNo.Text.ToString().Trim()+"'";
SqlCommand cmd_pwd = new SqlCommand(strCom,connStr); DataSet ds_pwd = new DataSet(); SqlDataAdapter da_pwd = new SqlDataAdapter(cmd_pwd); connStr.Open();
da_pwd.Fill (ds_pwd,"Pwd");
connStr.Close(); if(this.Password.Text.ToString().Trim()==ds_pwd.Tables["Pwd"].Rows[0]["UserPwd"].ToString().Trim())
{
BCMain main = new BCMain();
main.Show();
this.Hide();
}
else
{
MessageBox.Show("请再次输入正确密码!");
return;
}
}
我在form_Load
的时候,读取目录下的conn.ini文件,获得连接字符串。但是运行的时候报错
说:
--------------------------------------------------------------
一个托管的TypeLoadException发生在Form::OnLoad+0x15Form::OnLoad+0x15
Form::_SetVisibleNotify+0x1d
Control::set_Visible+0x1f
Application::Run::0x7
BCLogon::Main+0xa
---------------------------------------------------------------------------
然后我将LOad时间中读取链接字符串的语句注释掉后,界面就能显示出来了,
但是,在按确定,也就是判断判断用户名和密码对不对的时候,报错
显示错误信息:
-------------------------------------------------------------
一个托管的TypeLoadException发生在Application::Run+0xfApplication::Run+0xf
BCLogon::Maub+0xa
-------------------------------------------------------------BCLogon为登录的画面名谢谢各位拉!
{
StreamReader sw = new StreamReader("conn.ini");
c.BCConn = sw.ReadLine();
sw.Close();SqlConnection connStr = new SqlConnection();
connStr.ConnectionString = c.BCConn;
strCom="";
strCom="select CompaniesCode,CompaniesName from BCCompanies";
SqlCommand cmd_company = new SqlCommand(strCom,connStr);
//
DataSet ds_company = new DataSet();
//
SqlDataAdapter da_company = new SqlDataAdapter(cmd_company);
//
connStr.Open();
da_company.Fill (ds_company,"Company");
connStr.Close(); } private void BCLogon_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
DialogResult result=MessageBox.Show("确认要离开BarCode系统吗?","BarCode系统提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);
if(result==DialogResult.Yes)
{
e.Cancel=false;
Application.Exit();
}
else
{
e.Cancel=true;
}
} private void Confirm_Click(object sender, System.EventArgs e)
{
if(this.CompanyNo.Text.ToString().Trim()=="")
{
MessageBox.Show("请选择您要登录的公司");
return;
} if(this.UserNo.Text.ToString().Trim()=="")
{
MessageBox.Show("请选择登录用户名");
return;
} SqlConnection connStr = new SqlConnection();
connStr.ConnectionString = c.BCConn; strCom="";
strCom="select * from BCUser where UserNo = '"+this.UserNo.Text.ToString().Trim()+"' and CompaniesNo = '"+this.CompanyNo.Text.ToString().Trim()+"'";
SqlCommand cmd_pwd = new SqlCommand(strCom,connStr); DataSet ds_pwd = new DataSet(); SqlDataAdapter da_pwd = new SqlDataAdapter(cmd_pwd); connStr.Open();
da_pwd.Fill (ds_pwd,"Pwd");
connStr.Close(); if(this.Password.Text.ToString().Trim()==ds_pwd.Tables["Pwd"].Rows[0]["UserPwd"].ToString().Trim())
{
BCMain main = new BCMain();
main.Show();
this.Hide();
}
else
{
MessageBox.Show("请再次输入正确密码!");
return;
}
}
我在form_Load
的时候,读取目录下的conn.ini文件,获得连接字符串。但是运行的时候报错
说:
--------------------------------------------------------------
一个托管的TypeLoadException发生在Form::OnLoad+0x15Form::OnLoad+0x15
Form::_SetVisibleNotify+0x1d
Control::set_Visible+0x1f
Application::Run::0x7
BCLogon::Main+0xa
---------------------------------------------------------------------------
然后我将LOad时间中读取链接字符串的语句注释掉后,界面就能显示出来了,
但是,在按确定,也就是判断判断用户名和密码对不对的时候,报错
显示错误信息:
-------------------------------------------------------------
一个托管的TypeLoadException发生在Application::Run+0xfApplication::Run+0xf
BCLogon::Maub+0xa
-------------------------------------------------------------BCLogon为登录的画面名谢谢各位拉!
备注
当公共语言运行库无法找到程序集、程序集内的类型或者无法加载类型时引发 TypeLoadException。TypeLoadException 使用值为 0x80131522 的 HRESULT COR_E_TYPELOAD。有关 TypeLoadException 实例的初始属性值列表,请参见 TypeLoadException 构造函数。我没遇到过。这个是不是你用到的组件没有完全部署上去。或者你使用的部分组件是x86指令集的?尝试一下清除bin目录中的生成代码和引用的自己写的dll,重新用wince.net/ppc设备方式编译一下试试?^_^多谢楼主这么看得起。不过我也没遇到过。只能猜测到这里。
System_SR_chs.cab
sql.wce4.x86.cab我也将这些都拷贝过去安装试试不过,X86好像是通用型的CPU指令集。而PDA应该是ARM嵌入式CPU,不知道该用ARM的还是X86,我试试X86先
我的连接是这么写的:
c.BCConn = "server=scalatest.jdr.com.cn;database=BarCode;uid=sa;pwd=5570570";SqlConnection connStr = new SqlConnection();
connStr.ConnectionString = c.BCConn;
connStr.Open(); 出错。
不知道是不是因为PDA上的连接不能这么写,我换个写法试试。