Black Horse programmer -.net establishes a connection to the SQL Server database

Source: Internet
Author: User

 

-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ----------------------

 

In. net, ado.net is used to optimize database access.

Sqlconnection: the class used to establish a connection with the SQL Server server, indicating the opened database connection.

The connectionsetting attribute is used to set the string used to open the SQL Server database.

In the string, "server" indicates the name or network address of the SQL server instance to be connected, and "local" indicates that the instance is connected to a local computer.

User ID indicates the user name for SQL Server login

PWD indicates the logon password.

Database indicates the name of the database to be connected.

Then we can establish a database connection.

string ConStr = "server=(local);user id=ysm;Pwd=;DataBase=db_01";SqlConnection con = new SqlConnection(ConStr);

In this way, the connection to the database is realized.

 

-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ---------------------- For details, please refer to: http://net.itheima.com/

-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ----------------------

 

In. net, ado.net is used to optimize database access.

Sqlconnection: the class used to establish a connection with the SQL Server server, indicating the opened database connection.

The connectionsetting attribute is used to set the string used to open the SQL Server database.

In the string, "server" indicates the name or network address of the SQL server instance to be connected, and "local" indicates that the instance is connected to a local computer.

User ID indicates the user name for SQL Server login

PWD indicates the logon password.

Database indicates the name of the database to be connected.

Then we can establish a database connection.

string ConStr = "server=(local);user id=ysm;Pwd=;DataBase=db_01";SqlConnection con = new SqlConnection(ConStr);

In this way, the connection to the database is realized.

 

-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ---------------------- For details, please refer to: http://net.itheima.com/

Related Article

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.