MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

ADO.NET

ADO.NET Projects

ADO.NET Project 1

ADO.NET Examples

Examples

Use of CommandBuilder
Previous Home Next

CommandBuilder builds “Parameter” objects automatically and SqlCommandBuilder object to automatically create the DeleteCommand, the InsertCommand, and the UpdateCommand properties of the SqlCommand object for a SqlDataAdapter object,

Insert Data using SqlCommandBuilder
using System;
using System.Data;
using System.Data.SqlClient;
class stringbuildinginsert
{
static void Main(string[] args)
{
SqlConnection con = new SqlConnection(
"server=(local)\\SQLEXPRESS;database=Emp;
          Integrated Security=SSPI;");
SqlDataAdapter sda = new SqlDataAdapter
("SELECT ID, FirstName, LastName FROM Employee", con);
SqlCommandBuilder Cmdb = new SqlCommandBuilder(sda);
DataSet ds = new DataSet();
sda.Fill(ds);
DataRow drow = ds.Tables[0].NewRow();
drow["ID"] = 200;
drow["FirstName"] = "Kamal";
drow["LastName"] = "Mishra";
ds.Tables[0].Rows.Add(MyRow);
sda.Update(ds);
}
}

 

Delete Data using SqlCommandBuilder
using System;
using System.Data;
using System.Data.SqlClient;
class stringbuildinginsert
{
static void Main(string[] args)
{
SqlConnection con = new SqlConnection
("server=(local)\\SQLEXPRESS;database=Emp;Integrated 
Security=SSPI;");
SqlDataAdapter sda = new SqlDataAdapter
("SELECT ID, FirstName, LastName FROM Employee", con);
SqlCommandBuilder Cmdb = new SqlCommandBuilder(sda);
DataSet ds = new DataSet();
sda.Fill(ds);
DataColumn[] dc = new DataColumn[1];
dc[0] = ds.Tables[0].Columns[0];
dst.Tables[0].PrimaryKey = dc;
DataRow drow = MyDataSet.Tables[0].Rows.Find(1);
drow.Delete();
sdar.Update(ds);
}
}
Previous Home Next
>