执行存储过程没有效果,但是也不报错,但是存储过程在查询分析器里面执行正常
public void JiSuanZongHe(string faid,string bjid,string xsid)
{
string connectionString = ConfigurationSettings.AppSettings[ "CrmSqlConnect "];
string error = " ";
SqlConnection m_conn = new SqlConnection(connectionString);
m_conn.Open();
SqlCommand m_com = new SqlCommand( "P_JISUAN_ZHCJ ' "+faid+ " ', ' "+bjid+ " ', ' "+xsid+ " ', ' "+error+ " ' ", m_conn);
m_com.CommandType = CommandType.Text;
m_com.ExecuteNonQuery();
m_conn.Close();
}
------解决方案--------------------可能Command那吧,我也才学,你看看我的,这个
public void ExeuteNoQuery(string proc, SqlParameter[] paramlist)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[ "AdsysConnectionString "].ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = proc;
if(paramlist!=null && paramlist.Length> 0)
{
foreach(SqlParameter param in paramlist)
{
cmd.Parameters.Add(param);
}
}
cmd.ExecuteNonQuery();
conn.Close();
}
在实体类写个方法 调用这个方法,传参数列表和存储过程名字 就可以了。!
------解决方案--------------------public static bool DealData(params string[] QueryStrings) {
ConnectionString.Open();
SqlTransaction SqlTrans = ConnectionString.BeginTransaction();
SqlCommand Command=new SqlCommand();
Command.Connection=ConnectionString;
Command.Transaction=SqlTrans;
try
{
for(int i=0;i <QueryStrings.Length;i++)
{
Command.CommandText=QueryStrings[i];
if(Command.ExecuteNonQuery()==0)
return false;
}
SqlTrans.Commit();
return true;
}
catch
{
SqlTrans.Rollback();
return false;
}
finally
{
ConnectionString.Close();
Command.Dispose();
}
}
------解决方案--------------------SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings[ "CrmSqlConnect "]);
SqlCommand cmd=new SqlCommand();
cmd.Connection=conn;
conn.Open();
cmd.CommandType=CommandType.StoredProcedure;
cmd.CommandText= "p_corp_list_editresultcx ";
cmd.Parameters.Add( "@faid ",SqlDbType.NVarChar).Value=faid;