Công Nghệ SqlCommand in ado.net - Part 4

SqlCommand in ado.net – Part 4


- Advertisment -

Text version of the video


All ADO .NET Text Articles

All ADO .NET Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

In this video we will learn about
1. The Purpose of the SqlCommand object
2. Creating an instance of the SqlCommand class
3. When and how to use ExecuteReader(), ExecuteScalar() and ExecuteNonQuery() methods of the SqlCommand object.

Nguồn: https://chaoticpharmacology.com/

Xem thêm bài viết khác: https://chaoticpharmacology.com/cong-nghe/


  1. hello sir! why we have done totalrows.toString() when already the method executNonQuey is returning a integer value which we are storing in an integer variable?

  2. Sir can you put video of one small project then we come to know how to use all these regarding C# && asp.net..

  3. in Response.Write() we can use "n" instead of "<br/>", right? And why is it that "<br/>" works anyway? Because I don't think that would work in C++'s cout. Is <br> defined for C#?

  4. Hi,
    Following code is not working.

    using System;

    using System.Data.SqlClient;

    using System.Configuration;

    namespace TestData


    public class Program


    public static void Main()


    string CS= ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;

    SqlConnection con = new SqlConnection(CS);

    SqlCommand cm = new SqlCommand("");

    cm.CommandText = "select *from Students_Table";

    cm.Connection = con;


    SqlDataReader dr =cm.ExecuteReader();





    cm.CommandText = "delete from Students_Table where Id=1";

    int count = cm.ExecuteNonQuery();

    Console.WriteLine("No of rows deleted are" + count);

    cm.CommandText = "select count(Id) from Students_Table";

    count = (int)cm.ExecuteScalar();

    Console.WriteLine("Total students are" + count);





    If I run all execute methods at a time, on opening a connection only once. It is throwing an error as below.

    There is already an open DataReader associated with this Command which must be closed first.'

  5. I have no words man, thank you so much for these awesome and simple explanations. I have a test in 9 days and haven't managed to study properly because of my job. I sit here 2 or 3 hours a day listening to you and I get a full week of class in a day

  6. I'm facing a problem with web application I don"t get the data in the GridView at the browser but in the Windows Forms Application i can .

  7. I have to say thank you for creating this playlist. These videos are just such a great resource. Having said that, I have been struggling with a problem for the last few days and I just can't find the help to solve it all the way. I am not senior in C# so forgive me if I am missing something simple here. Here is the question – I am trying to write a script in SSIS which converts a System.Object into a list of strings so I can then select the Max value from all the strings, how can I do that exactly because using the data adapter just doesn't work for me. I don't care if i convert to a list of strings or a data column, or an array – I just need to select the Max value stored in the System.Object. Please help! And thanks again for these videos.

  8. Hi Venkat
    i am a beginner to ADO.Net
    This video is very help for learning things quicky..thanks alottt
    i tired delete command with ExecuteReader instead of ExecuteNonQuery.. and it deleted the row from table
    so what is the main difference between ExecuteReader and ExecuteNonQuery
    Please Help to understand..

  9. Why do we have to convert the total rows to ToString in Response.Write()? Can't we simply write as TotalRows and not TotalRows.ToString()?

  10. Oh guy! You saved my marks. Today I had an exam and it went wonderful. All because of you. Thank you so much! 😊

  11. I get an error with the line GridView1.DataBind();The intelesence does not show the DataBind() method at all.Thank you


Please enter your comment!
Please enter your name here

Latest news

Thuê mặt bằng làm quán ăn, nên chọn địa điểm thế nào?

Bạn đang muốn thuê mặt bằng làm quán ăn nhưng băn khoăn chưa biết chọn địa điểm như thế...

Nhận định bóng đá giữa Chelsea vs Southampton, 21h ngày 17/10

Chelsea vs Southampton là hai đội bóng có rất nhiều fan hâm mộ và được thế giới chú ý...

Cách cài Win từ ổ cứng: cả Win 7/8/8.1 và Win10 (làm mẫu với Win 10)

Hướng dẫn cách cài Win từ ổ cứng, áp dụng cho cả win 7/8/8.1 và win 10. Trong bài...

[Topgame] Top 9 game bắn súng online miễn phí hay nhất đầu 2018 | Android-IOS

Game bắn súng luôn là thể loại được hâm mộ nhất trong thế giới ảo, cho game thủ cơ...
- Advertisement -

Hướng dẫn tạo chú thích footnote trong Word | How to Insert Footnote in Word

Facebook: Google +: Cách tạo ghi chú, trích dẫn chú thích footnote cuối trang trong văn bản word Cách tạo Footnote Word,...

Cách chèn nhạc vào ảnh và video trên Facebook

Cách chèn nhạc vào ảnh và video trên Facebook. Gần đây, facebook đã cho ra mắt một tính năng khá...

Must read

Thuê mặt bằng làm quán ăn, nên chọn địa điểm thế nào?

Bạn đang muốn thuê mặt bằng làm quán ăn...

Nhận định bóng đá giữa Chelsea vs Southampton, 21h ngày 17/10

Chelsea vs Southampton là hai đội bóng có rất...
- Advertisement -

You might also likeRELATED
Recommended to you