数据访问的异常问题
我的程序入下所示:
using System;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
class Class1
{
string source= "server=(local);integrated security=SSPI;database=Northword ";
SqlConnection conn=new SqlConnection(source);
conn.Open();
try
{
SqlCommand aCommand=new SqlCommand( "RegionDelete ",conn);
aCommand.CommandType=CommandType.StoredProcedure;
aCommand.Parameters.Add(new SqlParameter( "@RegionID ",SqlDbType.Int,0, "RegionID "));
aCommand.UpdatedRowSource=UpdateRowSource.None;
aCommand.Parameters[ "@RegionID "].Value=6;
aCommand.ExecuteNonQuery();
Console.ReadLine();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
finally
{
conn.Close();
Console.ReadLine();
}
}
}
}
可是每次执行到try下面那一行,即SqlCommand aCommand=new SqlCommand( "RegionDelete ",conn);的时候就会出现异常,可是又捕获不到异常,这是为什么啊?
------解决方案--------------------RegionDelete是SP?
------解决方案--------------------是不是,你什么地方弄错了啊 ,你的程序,我试过了没错啊