Friday, April 18, 2008

A solution for inserting ,updating ,deleting database with class and stored procedure

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public class Class1
{
SqlConnection scn = new SqlConnection("Data Source=.;Initial Catalog=Routingmail;Integrated Security=True");

public Class1()
{


}
public void prc(string prcname, string[] prcnames, string[] prcvalues)
{
scn.Open();
SqlCommand cmd = new SqlCommand(prcname, scn);
cmd.CommandType = CommandType.StoredProcedure;
for(int i = 0; i <= prcnames.Length - 1; i++)
{
cmd.Parameters.Add(prcnames[i], prcvalues[i]);
}
cmd.ExecuteNonQuery();
scn.Close();
}
}

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...