Database Connection of ADO. NET database --- ShinePans,

Source: Internet
Author: User
Tags oracleconnection name database

Database Connection of ADO. NET database --- ShinePans,

ADO. NET technology mainly includes Connection, Command, DataReader, DataAdapter, DateSet, able and other six objects


1). The main function of the Connection object is to connect to the database (this object is also used for transaction processing)

2) The Command object is a database Command used to return data, modify data, run stored procedures, and send or retrieve parameter information.

3). The main function of the DataReader object is to read rows from the database in the stream-only mode.

4 ). the main function of the DataAdapter object is to fill the content in the database into the DataSet object. After modifying the data in the DataSety object, you can also notify the database of the modification information so that the data in the data domain database of the DataSet object remains consistent.

5 ). the DataSet object is ADO. NET, which supports ADO. the core object of the NET disconnected Distributed Data solution. The DataSet object is a database container and can be regarded as a database that exists in the memory, no matter what the data source is, it provides consistent relational programming models.

6) DataTable can be understood as a data table in memory.


The comprehensive application of these commands serves the program


In ADO.net, the Connection object Connection database Connection object includes four versions: SQLConnection, OleDbConnection, OracleConnection, and OdbcConnection. sqlConnection is used to connect to the SQL Server database, OleDbConnection is used to connect to the database exposed in OLE DB mode, OracleConnection is used to connect to the Oracle database, and OdbcConnection is used to connect to the database exposed using ODBC
SqlConnection: The SqlConnection object is used to connect to the database. The most important method is the Open method and the Close method. The Open method is used to Open the connection to the database. The Close method is used to Close the connection to the database.
Attribute: ConnectionString gets or sets the State of the string used to Open the SQL Sever database to indicate the State of SqlConnection. Method: Open uses the attribute setting specified by Connection to Open Close and Close the Connection to the database.
Connection string "server = locahost; database = db_test; uid = sa; pwd = sqlserver" "server =,; database = db_test; Trust_Connection = true"
Localhost database server name db_test database name uid = sa username qwd = sqlserver database Password server =,; database server name database = db_test; database name Trusted_Connection = true use trusted connection
Example of connecting sentence: class program {static void Main () {string connection = "server =,; database = db_test; Trusted_Connection = true "; // create a database connection string SqlConnection SC = new SqlConnection (); // create a SqlConnection object SC. connectionString = connection; try {SC. open (); Console. writeLine ("database connection enabled");} catch (Exception ex) {Console. writeLine ("Opening Database Error: {0}", ex. message); // error Message displayed on the console} finally {SC. close (); Console. writeLine ("database disabled");} System. console. readLine ();}
}


How does adonet connect to the SQL database?

Initial Catalog is used in ole db. You do not need to use SQL.
Initial Catalog change it to database = is the name of the connected database
Server =.; database = database uid =; pwd =;

After the connection, you can enter the SQL command in SqlCommand cmd = new SqlCommand ().

But click a button to automatically create a database. I didn't try to help you study it yourself''

How does adonet connect to the SQL database?

String ConStr = "server =.; database = adoteset; uid = username; pwd = password ;";

Or
Catch (Exception ex)
{
MessageBox. Show (ex. ToString ());
}

So we can see what the specific error is.

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.