string strUpdate="CREATE PROCEDURE sp_update @name varchar(50), @id int AS update studenttable set name=@name where studentid=@id";
if(cn==null)
cn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("cm"));
cn.Open();
SqlCommand temp=new SqlCommand(strUpdate,cn);
temp.ExecuteNonQuery();
if(cmd==null)
cmd=new SqlCommand("select name,sex,studentid,password from studenttable",cn);
cmd.CommandType=CommandType.StoredProcedure;
cmd=new SqlCommand("sp_update",cn);
cmd.Parameters.Add("@name",SqlDbType.VarChar,50);
cmd.Parameters.Add("@id",SqlDbType.Int,4);
cmd.Parameters["@name"].Value="sdfsfsfs";
cmd.Parameters["@id"].Value=34;
cmd.ExecuteNonQuery();第 1 行: 'sp_update' 附近有语法错误。???????
if(cn==null)
cn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("cm"));
cn.Open();
SqlCommand temp=new SqlCommand(strUpdate,cn);
temp.ExecuteNonQuery();
if(cmd==null)
cmd=new SqlCommand("select name,sex,studentid,password from studenttable",cn);
cmd.CommandType=CommandType.StoredProcedure;
cmd=new SqlCommand("sp_update",cn);
cmd.Parameters.Add("@name",SqlDbType.VarChar,50);
cmd.Parameters.Add("@id",SqlDbType.Int,4);
cmd.Parameters["@name"].Value="sdfsfsfs";
cmd.Parameters["@id"].Value=34;
cmd.ExecuteNonQuery();第 1 行: 'sp_update' 附近有语法错误。???????
------------------
好象不允许用这个来命名
改存储过程的名字吧
@name varhcar(50),
@id int
as
update studenttable set name=@name where studentid=@id