public bool
SavePackage(PackageModel data, ref string ErrMsg)
{
String result = "";
string sql = "insert
into Package (PackageName,Price) values(@PackageName,@Price)";
try
{
using (SqlConnection
dbcon = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnection"].ToString()))
{
using
(SqlCommand cmd = new SqlCommand(sql, dbcon))
{
SqlParameter
PackageName = new SqlParameter("@PackageName",
SqlDbType.VarChar);
PackageName.Value =
data.PackageName;
SqlParameter Price = new
SqlParameter("@Price", SqlDbType.Int);
Price.Value = Convert.ToInt32(data.Price); cmd.Parameters.Add(PackageName); cmd.Parameters.Add(Price);
if (dbcon.State == ConnectionState.Closed) dbcon.Open();
cmd.ExecuteNonQuery(); result = "1";
}
}
}
catch
(Exception ex)
{
ErrMsg = ex.Message;
}
if (result
== "1")
return true;
else
return false;
}
No comments:
Post a Comment