Home > Net >  Connect to the database
Connect to the database

Time:10-05

Program teaching video remote connect to the database, in view of the c #,

CodePudding user response:

This directly with the project of the web. Config in & lt; Appsettings> Configure line, such as:



If use EF is the more simple, you can surf the Internet search, very simple

CodePudding user response:

See the MSDN:
Use ADO.NET to access the data
https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-1.1/e80y5yhx (71) v=vs.

CodePudding user response:

 

DataSet ds=new DataSet();
SqlConnection conn=new SqlConnection (" connection string ");//a connection object
Conn. The open ();//open the connection to the database
SqlCommand CMD=new SqlCommand (" database operations statement ", conn);
SqlDataAdapter da=new SqlDataAdapter (" database query, "conn);//set up break open connection object, one-time read into memory, the data need not connect to the database again
CMD. ExecuteScalar ();//return the first line of the query in the first column
CMD. ExecuteNonQuery ();//returns the number of rows affected, is to increase the delete modify, success will return to greater than zero, failure is less than 0
CMD. ExecuteReader ();//return the query object, note that this is breaking connections, break a meeting report error
Da. The fill (ds, "table");//the data to fill in the table to the dataset
//these is to connect to the database operation, almost have not understand can look at the official documentation

CodePudding user response:

Send you a ADO.NET tutorial, I just look at the https://www.cnblogs.com/best/p/7714500.html

CodePudding user response:

Online to find a DBHelper class, learn to use first, slowly to understand
  •  Tags:  
  • C#
  • Related