在 System.Data.SqlClient.SqlException 中第一次偶然出现的“System.Data.dll”类型的异常 20
程序源代码private:System::VoidbtnOK_Click(System::Object^sender,System::EventArgs^e){Syste...
程序源代码
private: System::Void btnOK_Click(System::Object^ sender, System::EventArgs^ e) {
System::Data::SqlClient::SqlConnection ^cn = gcnew System::Data::SqlClient::SqlConnection();
cn->ConnectionString ="Initial Catalog=学生成绩管理; Data Source=" + txtServer->Text + "; Integrated Security=SSPI;";
panel1->Visible =false;
lblWater->Visible =true;
this->Cursor = Cursors::WaitCursor;
this->Refresh();
try
{
cn->Open();
lblWater->Visible =false;
panel1->Visible =true;
this->Cursor = Cursors::Default;
sqlcn = cn;
}
catch( ...)
{
MessageBox::Show("连接数据库失败,请认真阅读系统说明书。","异常",MessageBoxButtons::OK,MessageBoxIcon::Error;lblWater->Visible = false;
panel1->Visible =true;
this->Cursor = Cursors::Default;
return;
}
//记录服务器
Microsoft::Win32::RegistryKey ^regkey;
regkey = Microsoft::Win32::Registry::CurrentUser->CreateSubKey("学生成绩管理系统");
regkey->SetValue("服务器",txtServer->Text);
this->DialogResult = System::Windows::Forms::DialogResult::OK;
this->Close();
}
调试通过,运行就出现上述问题。 展开
private: System::Void btnOK_Click(System::Object^ sender, System::EventArgs^ e) {
System::Data::SqlClient::SqlConnection ^cn = gcnew System::Data::SqlClient::SqlConnection();
cn->ConnectionString ="Initial Catalog=学生成绩管理; Data Source=" + txtServer->Text + "; Integrated Security=SSPI;";
panel1->Visible =false;
lblWater->Visible =true;
this->Cursor = Cursors::WaitCursor;
this->Refresh();
try
{
cn->Open();
lblWater->Visible =false;
panel1->Visible =true;
this->Cursor = Cursors::Default;
sqlcn = cn;
}
catch( ...)
{
MessageBox::Show("连接数据库失败,请认真阅读系统说明书。","异常",MessageBoxButtons::OK,MessageBoxIcon::Error;lblWater->Visible = false;
panel1->Visible =true;
this->Cursor = Cursors::Default;
return;
}
//记录服务器
Microsoft::Win32::RegistryKey ^regkey;
regkey = Microsoft::Win32::Registry::CurrentUser->CreateSubKey("学生成绩管理系统");
regkey->SetValue("服务器",txtServer->Text);
this->DialogResult = System::Windows::Forms::DialogResult::OK;
this->Close();
}
调试通过,运行就出现上述问题。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询