1
Answer

Insert data in database using user-defined method

ROHIT SINHA

ROHIT SINHA

6y
586
1
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)