TAILIEUCHUNG - Beginning C# 2005 Databases PHẦN 6

Như bạn có thể thấy, bằng cách sử dụng mã theo cách này là dễ dàng hơn nhiều. Có lẽ bất lợi duy nhất là mỗi bộ chuyển đổi dữ liệu mở và đóng một kết nối một cách độc lập. Tuy nhiên, đó là một cái gì đó mà bạn có thể tùy chỉnh nếu bạn muốn - các card dữ liệu có một kết nối | Accessing Databases Programmatically catch Exception ex Process exception. Finally the code used to navigate the relationship is re-written using the new strongly typed methods and properties in the classes generated by the data source foreach classificationRow in Classification 0 childRows if 0 foreach storyRow in childRows Story 0 else No stories. As you can see using code in this way is much easier. Perhaps the only disadvantage is that each data adapter opens and closes a connection independently. However that s something that you can customize if you want the data adapters have a Connection property that you can use to set your own connection to use which you could open and close manually to prevent the extra processing. To be honest however unless you are using a lot of data adapters this overhead will be minimal because connection pooling will be used and the improved code simplicity is more than worth the cost in most applications. Summary In this chapter you have extended your knowledge of to the point where you can use it in your applications without data binding to controls. You have learned to perform basic operations such as making connections and executing commands as well as using data readers to read data and data adapters and DataSet objects to obtain disconnected data for reading and modification. You ve also seen how to use powerful typed DataSet classes to make your code simpler and save you a lot of work. Specifically you have looked at How to make database connections using the SqlConnection class and how to store connection strings in and configuration files. You learned why the state of 239 Chapter 6 the .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.