Difference between w executequery and executenonquery in c#
Answers
Answered by
0
(1) Execute query is used to retrieve data records for viewing..It returns a SQLdatareader object.
for example.
(A.) instantiate a new command with a query and connection.
$yntax :-
Sqlcommand cmd=newsql command("Select category Name from categories",conn);
(B.) call execute reader to get query results
$yntax:-
SqlDatareader rdr=cmd.Executereader();
(2) Nonexecute query is just only used to insert/delete/update the data records
To insert data :-
$yntax:-
//prepare command string
string insert string=@"
insert into categories
(categories Name,Description)
values('Miscellaneous','whatever doesn''t fit elsewhere')";
To delete data:-
$yntax:-
//prepare command string
string delete string=@"
delete from categories
where categories name='others'";
To update data:-
$yntax:-
//prepare command string
string update string=@"
update categories
set categories name='others'"
where category Name='Miscellaneous'";
Hope my answer helps you.....
Mark my answer as brainliest please.
for example.
(A.) instantiate a new command with a query and connection.
$yntax :-
Sqlcommand cmd=newsql command("Select category Name from categories",conn);
(B.) call execute reader to get query results
$yntax:-
SqlDatareader rdr=cmd.Executereader();
(2) Nonexecute query is just only used to insert/delete/update the data records
To insert data :-
$yntax:-
//prepare command string
string insert string=@"
insert into categories
(categories Name,Description)
values('Miscellaneous','whatever doesn''t fit elsewhere')";
To delete data:-
$yntax:-
//prepare command string
string delete string=@"
delete from categories
where categories name='others'";
To update data:-
$yntax:-
//prepare command string
string update string=@"
update categories
set categories name='others'"
where category Name='Miscellaneous'";
Hope my answer helps you.....
Mark my answer as brainliest please.
Similar questions