Asp.net and Oracle, SQL Server, and Access Database (1/8)

Source: Internet
Author: User

The database connection code provided in this article is an asp.net and Oracle, SQL Server, and Access database class. If you are an asp.net developer, you will be able to use it. net can be connected to Oracle, SQL Server, and Access. If you use this database, you can directly use it. It also solves various database connection problems.

The connection code of this database tutorial is an asp tutorial. net and oracle, SQL server, and access database. If you are an asp.net tutorial developer, you will be able to use it. net can be connected to oracle, SQL server, and access. If you use this database, you can directly use it. It also solves various database connection problems.

Using system;
Using system. collections;
Using system. collections. specialized;
Using system. data;
Using system. data. sqlclient;
Using system. data. oledb;
Using system. data. oracleclient;
Using system. configuration;
Using system. reflection;

Namespace systemframework. dal
{
/** // <Summary>
/// All rights reserved
/// Basic Data Access class
/// You can modify the settings to meet your project requirements.
/// </Summary>
Public class databaselayer
{
// Database connection string (configured in web. config)
// <Add key = "connectionstring" value = "server = 127.0.0.1; database = database; uid = sa; pwd ="/>
Private string connectionstring;
Public string conntionstring
{
Get
{
Return connectionstring;
}
Set
{
Connectionstring = value;
}
}


Public databaselayer (string strconnect, string datatype)
{
This. conntionstring = strconnect;
This. dbtype = datatype;
}


Public databaselayer ()
{
This. connectionstring = configurationsettings. apps tutorial ettings ["connectionstring"];
This. dbtype = configurationsettings. etettings ["datatype"];
}

/** // <Summary>
/// Database Type
/// </Summary>
Private string dbtype;
Public string dbtype
{
Get
{
If (dbtype = string. empty | dbtype = null)
{
Return "access ";
}
Else
{
Return dbtype;
}
}
Set
{
If (value! = String. empty & value! = Null)
{
Dbtype = value;
}
If (dbtype = string. empty | dbtype = null)
{
Dbtype = configurationsettings. etetype ["datatype"];
}
If (dbtype = string. empty | dbtype = null)
{
Dbtype = "access ";
}
}
}

 

1 2 3 4 5 6 7 8

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.