Asp. net connection to open the database

Source: Internet
Author: User

1 // test whether the connection string is successful
2 # region
3 using System;
4 using System. Collections. Generic;
5 using System. Linq;
6 using System. Web;
7 using System. Web. UI;
8 using System. Web. UI. WebControls;
9 using System. Data. SqlClient;
10 using System. Configuration;
11
12 public partial class test_Default: System. Web. UI. Page
13 {
14 protected void Page_Load (object sender, EventArgs e)
15 {
16 string str = ConfigurationManager. ConnectionStrings ["haqiuConnectionString"]. ConnectionString;
17 SqlConnection strConn = new SqlConnection (str );
18 if (strConn = null)
19 {
20 Response. Write ("the connection string is empty! ");
21}
22 else
23 {
24 Response. Write ("the connection string is not empty! ");
25}
26}
27}
28 # endregion
29
30 // open the database connection
31 # region
32 using System;
33 using System. Collections. Generic;
34 using transaction E

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.