c#中执行存储过程的方法
public static void ExecuteProc(string procname,string parameter1, string paramete2,string paramete3)
{
private static string cnnString = "Data Source=XIAO;Initial Catalog=ingonline;Integrated Security=True";
SqlConnection con = new SqlConnection(cnnString);
SqlCommand com = new SqlCommand();
con.Open();
com.CommandType = CommandType.StoredProcedure;
//给出存储过程的名字
com.CommandText = procname;
//给出参数的值
com.Parameters.Add("@SID",SqlDbType.NChar,10);
com.Parameters["@SID"].Value=parameter1;
com.Parameters.Add("@paperID",SqlDbType.NChar,10);
com.Parameters["@paperID"].Value = paramete2;
com.Parameters.Add("@subjectID",SqlDbType.NChar,10);
com.Parameters["@subjectID"].Value = paramete3;
com.Connection = con;
}执行该方法:ExecuteProc("scorecount1", "1", "1", "1");请问各位高手上述方法有什么错误,怎么不能执行存储过程呢??急等。
public static void ExecuteProc(string procname,string parameter1, string paramete2,string paramete3)
{
private static string cnnString = "Data Source=XIAO;Initial Catalog=ingonline;Integrated Security=True";
SqlConnection con = new SqlConnection(cnnString);
SqlCommand com = new SqlCommand();
con.Open();
com.CommandType = CommandType.StoredProcedure;
//给出存储过程的名字
com.CommandText = procname;
//给出参数的值
com.Parameters.Add("@SID",SqlDbType.NChar,10);
com.Parameters["@SID"].Value=parameter1;
com.Parameters.Add("@paperID",SqlDbType.NChar,10);
com.Parameters["@paperID"].Value = paramete2;
com.Parameters.Add("@subjectID",SqlDbType.NChar,10);
com.Parameters["@subjectID"].Value = paramete3;
com.Connection = con;
}执行该方法:ExecuteProc("scorecount1", "1", "1", "1");请问各位高手上述方法有什么错误,怎么不能执行存储过程呢??急等。
com.Connection = con;
com.ExecuteNonQuery();
2.@SID @paperID @subjectID 和存储过程的参数名是不是一样的
要引起来···然后保证存储过程没有错误!设置断点,单步调试下!