Asp. Solution to the MSSQL Server 2005 database without LINQ access in net

Source: Internet
Author: User
Tags microsoft sql server microsoft sql server 2005 mssql mssql server connectionstrings

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;
}

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.