//Access
using System.Data;
using System.Data.OleDb;
connString ="Provider =Microsoft.Jet.OleDb.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("~/App_Data/MyDataBase.mdb");
//SQL server
using System.Data;
using System.Data.SqlClient;
//SQL2005
connString="Data Source=zhou\\sql2005;Initial Catalog=AspNetStudy;Persist Security Info=True;User ID=sa;Password=123456");
//SQL2008
connString = @"server=LENOVO-AA\MYDATABASE;database=Database;Trusted_Connection=True";
//MySQL
using MySQLDriverCS;
using System.Net;
using System.Text;
using CoreLab.MySql;
using System.Data.Odbc;
using MySql.Data.MySqlClient;
MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString("localhost","mysql","root","",3306).AsString);
connString = "User Id=root;Host=localhost;Database=qing;password=qing";
//SyBase
Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=数据库名;User ID=用户名;Data Source=数据源;Extended Properties="";Server Name=ip地址;Network Protocol=Winsock;Server Port Address=5000;
//Oracle
using System.Data;
using System.Data.OracleClient;
connString="Data Source=sky;user=system;password=manager;";
//IBM DB2
connStri = "Driver={IBM DB2 ODBC DRIVER};Database=sample;hostname=192.168.1.46;port=50000;protocol=TCPIP; uid=admin; pwd=admin";
C#连接各种数据库语句(实例)
本文转载:CSDN博客