SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE work
@id int=0,
@name nchar(10),
@age nchar(10),
@address nvarchar(max)
as
BEGIN
SET NOCOUNT ON;
SELECT * from Work
END
GO
------------------------------------------
//调用存储过程里面的内容(开始)
SqlCommand command1 = new SqlCommand();
command1.CommandType = CommandType.StoredProcedure;
command1.CommandText = "QQtable_a";
SqlParameter p = new SqlParameter();
p.ParameterName = "@useName";
p.Value = useName;
command1.Parameters.Add(p);
=============================
public int Insert(string id, string name, string age, string address)
{
int result = 0;
string connstring = "Data Source=PC9;Initial Catalog=WebDatabase;Integrated Security=True";
SqlConnection conn = new SqlConnection(connstring);
SqlCommand cmd = new SqlCommand("sp_web", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
cmd.Parameters.AddWithValue("@ID", id);
cmd.Parameters.AddWithValue("@Name", name);
try
{
result = cmd.ExecuteNonQuery();
}
catch
{
result = -1;
}
finally
{
conn.Close();
}
return result;
}