alter PROCEDURE t_constru_standar_Insert
-- Add the parameters for the stored procedure here
@CodeNum varchar(100),
@TitleContent varchar(100),
@Description varchar(1000),
@StandardType varchar(50),
@StandardType2 varchar(50),
@IsEffective varchar(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into dbo.t_constru_standard (
[CodeNum],
[TitleContent],
[Description],
[StandardType],
[StandardType2],
[IsEffective]
)
values(
@CodeNum,
@TitleContent,
@Description,
@StandardType,
@StandardType2,
@IsEffective
)
declare @i int
set @i=@@ERROR
return @i
END
GO
public static int ExecuteSql(string SQLString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand(SQLString, connection))
{
try
{
connection.Open();
int rows = cmd.ExecuteNonQuery();
return rows;
}
catch (System.Data.SqlClient.SqlException E)
{
connection.Close();
throw new Exception(E.Message);
}
}
}
}
使用ls:需要将SET NOCOUNT ON; 改成OFF,不然是不会返回受影响行的
当然一般使用使用SELECT @@ROWCOUNT AS Rows ; SET NOCOUNT OFF会产生不少网络流量,尽量不用吧。