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