ROHIT SINHA

ROHIT SINHA

  • 1.7k
  • 202
  • 1.4k

Insert data in database using user-defined method

May 17 2018 2:33 PM
Hi all
 
I want to create a user-defined method which helps to insert any type of data into the database For example 
 
public DataTable BindGrid(string proc_nme)
{
con.Open();
DataTable dt = new DataTable();
SqlDataReader dr;
cmd = new SqlCommand(proc_nme, con);
dr = cmd.ExecuteReader();
dt.Load(dr);
return dt;
}
 
This is the method for getting data from the database we have to only pass the procedure name. As the same, I want to create a method for insertion.
Thanks in advance.  
 

Answers (1)