c#-Database access Technology ado.net--CREATE database connection class and database operation method and simple data add, delete, modify, view

Source: Internet
Author: User

Database access Technology ADO

The data in the database is extracted into memory and presented to the user to see
It is also possible to write in-memory data to the database

is not the only database access technology, but it is the lowest level of database access technology

1. Create a database and set the primary foreign key relationship

2. Create a new C # project, create a database connection class and a database operation method

A. Reference database using System.Data.SqlClient; B. Creating a database connection class: First write the connection string, and in the instantiation of the connection class

C. Creating a Database action method (not an instantiated class here) d. Open database → perform action → close database

=====================================================================================================

(1) Delete information from the database

=====================================================================================================

(2) Adding information from a database

====================================================================================================

(3) Modify the information in the database

=====================================================================================================

(4) Query the information in the database, Br. Read () returns the type of object

① This method disadvantage: Br[n] do not know which data, need to modify the time required to index, so you can use the br["column name"], at this time, the modification does not need a number of indexes, you can clearly see which column

② This query out of the information, the male and female display is True or False, how can the normal display of male or female?

Because Br. Read () Returns the object type, and True or FALSE is a bool type, so a conversion is required

③ How to show birthday only date?

④ How to display nationalities and classes as corresponding Chinese characters

c#-Database access Technology ado.net--CREATE database connection class and database operation method and simple data add, delete, modify, view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.