分别贴上存储过程代码,和程序代码,麻烦高手看一下!
——————————————————————
CREATE PROCEDURE test
as
begin
insert into T_User(userName,email,password) values('1111111','[email protected]','1111111')
end
-----------------在查询分析器可以正常执行
SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = new SqlCommand();
                da.SelectCommand.Connection = Conn;
                da.SelectCommand.CommandText = "test";
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
---------------在后台就执行不了。。 

解决方案 »

  1.   


    CREATE PROCEDURE test
    as
    begin
    insert into T_User(userName,email,password) values('1111111','[email protected]','1111111')
    end
    G0  --最后加上GO 试试
      

  2.   

     SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "test"; 
     
     cmd.ExecuteNonQuery();
      

  3.   


     String constr = "Data Source=KMGOAL;Initial Catalog=Northwind;Integrated Security=True";
               //关键代码:
                 SqlConnection con = new SqlConnection(constr);
                SqlCommand scd = new SqlCommand("test", con);
                scd.CommandType =CommandType.StoredProcedure;
              
                con.Open();
                scd.ExecuteNonQuery( );
                con.Close();
      

  4.   

    SqlConnection conn=new SqlConnection(“connectionString”);   
    SqlDataAdapter da = new SqlDataAdapter();   
    da.selectCommand = new SqlCommand();   
    da.selectCommand.Connection = conn;   
    da.selectCommand.CommandText = "";   
    da.selectCommand.CommandType = CommandType.StoredProcedure;  
    da.Fill(ds);
      

  5.   

    using(SqlConnection con = new SqlConnection(constr))
    {
    SqlCommand scd = new SqlCommand("test", con);
    scd.CommandType =CommandType.StoredProcedure;
    con.Open();
    scd.ExecuteNonQuery( );
    con.Close();
    }