如何在将数据库绑定到详细信息视图之前验证数据库中的字段
在进入详细信息视图之前,我有一些需要验证的字段
例如,应该消除空值字段......并且需要为
此表中的外键字段(即其他表中的数据)
我以为我可以在 ondatabinding 事件中做到这一点......
受保护的无效dvDataBinding(对象发送者,EventArgs e){}
在以下函数中,我将传递 req_ID ..
详细信息视图中的数据绑定...
public DataSet GetExceptionDataDetailedView(string strWorkRequestID)
{
DBManager objDBManager = new DBManager();
StringBuilder strSQL = new StringBuilder();
StringBuilder strColName = new StringBuilder(); //string strTableField;
DataSet objDataSet;
try
{
strSQL.Append("SELECT * FROM work_request where work_request_id='");
strSQL.Append(strWorkRequestID);
strSQL.Append("'");
// Open the connection object
objConnection = objDBManager.OpenDBConnection();
//Create a command object to execute the Store procedure
objCommand = new MySqlCommand();
objCommand.CommandText = strSQL.ToString();
objCommand.CommandType = CommandType.Text;
objCommand.Connection = objConnection;
MySqlDataAdapter objDataAdapter = new MySqlDataAdapter(objCommand);
objDataSet = new DataSet();
objDataSet.Tables.Clear();
objDataAdapter.Fill(objDataSet);
}
catch (MySqlException exSQL)
{
throw exSQL;
}
catch (Exception exGeneral)
{
throw exGeneral;
}
finally
{
//close the connection object
objDBManager.CloseDBConnection();
}
return objDataSet;
}
提前致谢