新人求大婶帮忙,代码出现问题
namespace WebApplication1.cs{
/// <summary>
///
/// </summary>
sealed internal class StoredProcedure : IDisposable {
public string ErrorMessage = "";
private System.Data.SqlClient.SqlCommand command;
public StoredProcedure(string sqlText){
ConfigManager config =new ConfigManager();
command = new SqlCommand(sqlText, new SqlConnection(config.DALConnectionString));
command.Connection.Open();}
/// <summary>
///
/// </summary>
public void Dispose(){
if(command!=null)
{
SqlConnection connection=command.Connection;
Debug.Assert(connection!=null);
command.Dispose();
command=null;
connection.Dispose();
}
}
/// <summary>
/// <returns></returns>
/// </summary>
public int Run()
{
if (command != null)
{
throw new ObjectDisposedException(GetType().FullName);
try
{
command.ExecuteNonQuery();
return 1;
}
catch (Exception e)
{
ErrorMessage = e.Message;
return 0;
}
}
}
/// <summary>
///
/// </summary>
/// <param name="dataTable"></param>
/// <returns></returns>
public int Run(DataTable dataTable){
if(command==null)
throw new ObjectDisposedException(GetType().FullName);
try{
SqlDataAdapter dataAdapter =new SqlDataAdapter();
dataAdapter.SelectCommand= command;
dataAdapter.Fill(dataTable);
return 1;
}
catch(Exception e){
ErrorMessage=e.Message;
return 0;
}
}
}
run()部分显示不是所以数据有返回值,try部分显示无法访问代码,求教怎么该