日期:2014-05-19  浏览次数:20760 次

登录信息提示系统错误
private   void   button1_Click(object   sender,   EventArgs   e)
{


for   (int   i=0;i <myTable.Rows.Count;i++)
{
this.myRow   =   myTable.Rows[i];
//只有当输入的用户名和密码同时对应上数据库中记录时,才能通过校验
if   (myRow[2].ToString().Trim()==this.textBox1.Text.ToString().Trim()   &&   myRow[3].ToString().Trim()==this.textBox2.Text.ToString().Trim())
{
blCanLogin   =   true;
strUser   =   myRow[2].ToString().Trim();//保存用户名
strDep   =   myRow[4].ToString().Trim();//保存权限
this.Close();//关闭窗体
return;
}
}
}

//根据输入的SQL语句检索数据库数据
public   DataSet   SelectDataBase(string   tempStrSQL,string   tempTableName)
{  
this.strSQL   =   tempStrSQL;
this.myConnection   =   new   SqlConnection(ConnectionString);
this.da   =   new   SqlDataAdapter(this.strSQL,this.myConnection);
this.ds.Clear();
this.da.Fill(ds,tempTableName);
return   ds;//返回填充了数据的DataSet,其中数据表以tempTableName给出的字符串命名
}

//数据库数据更新(传DataSet和DataTable的对象)
public   DataSet   UpdateDataBase(DataSet   changedDataSet,string   tableName)
{
this.myConnection   =   new   SqlConnection(ConnectionString);
this.da   =   new   SqlDataAdapter(this.strSQL,this.myConnection);
this.sqlCmdBld   =   new   SqlCommandBuilder(da);
this.da.Update(changedDataSet,tableName);
return   changedDataSet;//返回更新了的数据库表
}


当输入帐号密码以后系统老是说

未处理的“System.Data.SqlClient.SqlException”类型的异常出现在   system.data.dll   中。

其他信息:   系统错误。

而且将错误信息指向 第二段中 " this.da.Fill(ds,tempTableName); "

请问这是哪样问题?应该左右解决?我的是winform窗口

------解决方案--------------------
try


this.strSQL = tempStrSQL;
this.myConnection = new SqlConnection(ConnectionString);
conn.Open();
SqlCommand myCommand = new SqlCommand(this.strSQL,myConnection );

this.da = new SqlDataAdapter(myCommand );
this.ds.Clear();
this.da.Fill(ds,tempTableName);
conn.Close();
return ds;