C # Database Help class, including creating a database, deleting a database, and restoring a database

Source: Internet
Author: User

The database connection string is read from the configuration file. Code Using System;
Using System. Collections;
Using System. Collections. Specialized;
Using System. Data;
Using System. Data. SqlClient;
Using System. Configuration;
Using System. Data. Common;
Using System. Collections. Generic;
Namespace Maticsoft. DBUtility
{
/// <Summary>
/// Data Access abstract basic class
/// </Summary>
Public abstract class DbHelperSQL
{
// <? Xml version = "1.0" encoding = "UTF-8"?>
// <Configuration>
// <Deleetask>
// <! -- Connection string of the main program -->
// <Add key = "connection" value = "server = CONTRON-CAD9158; uid = sa; pwd = sa; database = syt"/>
// <! ---->
// <Add key = "connectionzt" value = "server = CONTRON-CAD9158; uid = sa; pwd = sa; database = syt_qwerthjkl"/>
// <! -- Connection string of the master SQLServer -->
// <Add key = "ConnectServer" value = "server = CONTRON-CAD9158; uid = sa; pwd = sa; database = master"/>
// <! -- Create a database connection string -->
// <Add key = "connInit" value = "data source = CONTRON-CAD9158; user id = sa; password = sa; persist security info = false; packet size = 4096"/>
// <! -- SQLServer installation directory -->
// <Add key = "sqlServerData" value = "C: Program FilesMicrosoft SQL ServerMSSQLData"/>
/// </AppSettings>
// </Configuration>
// Database connection string (configured in web. config). You can dynamically change connectionString to support multiple databases.
Public static string connectionString = PubConstant. ConnectionString;
Public static string connectionString = System. Configuration. ConfigurationSettings. deleettings ["connection"];
Public

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.