ASP Tutorial The Tutorial solution for using LINQ to access the MSSQL Server 2005 database in. Net
The ASP.net tutorial application's data access is done through Ado.net, Ado.net enables the Web application to quickly access data from a variety of data sources.
Instead of using LINQ to access the database in ASP.net, you can access Microsoft SQL Server 2005 directly by writing a SQL text
1. Add reference system.configuration and use the namespace using System.Configuration in your program.
2. "Configurationmanager.connectionstrings[" ConnectionString "].connectionstring" The strings within the quotation marks in brackets and my project Web.config properties in <connectionstrings></connectionstrings> tags in the configuration file "Name=" String inconsistency for Mywebconnectionstrings "". The correct should be the string in property name.
3. The database connection is not open. Because my program lacks L. "Sqlcon.open ();" This code.
Using System.Data.SqlClient;
Using System.Configuration;
protected void Setorders (Sting morders)
{
String sqlconnstr = configurationmanager.connectionstrings["Mywebconnectionstrings"].connectionstring;
SqlConnection sqlcon = new SqlConnection (SQLCONNSTR);
SqlCommand commd = new SqlCommand ();
Commd.connection = Sqlcon;
Sqlcon.open ();
Commd.commandtext = "Update orderlist set status = 1 where (OrderID in (" + Mpayingnum + ")" + ")";
SqlDataReader SqlDataReader = Commd.executereader ();
COMMD = null;
Sqlcon.close ();
Sqlcon = null;
}