执行存储过程没有效果,但是也不报错,但是存储过程在查询分析器里面执行正常
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;
cmd.Parameters.Add( "@bjid ",SqlDbType.NVarChar).Value=bjid;
cmd.Parameters.Add( "@xsid ",SqlDbType.NVarChar).Value=xsid;
cmd.Parameters.Add( "@error ",SqlDbType.NVarChar).Value=error;
cmd.ExecuteNonQuery();
[解决办法]
用事件查看器看一下
[解决办法]
帮顶 !
[解决办法]
1先在查询分析器中看能不能搞到结果
2. P_JISUAN_ZHCJ这是应该是你的存储过程名吧,没看到你的代码中有体现调用的呀
3. m_com.CommandType = CommandType.Text; 这个好像不对的吧
4.m_com.ExecuteNonQuery(); 没有看到有什么东东接收你的返回的东东呀.实在不行,你把他response.write看一下啦