程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> 關於C# >> C#連接各種數據庫語句(實例)

C#連接各種數據庫語句(實例)

編輯:關於C#
 

//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";

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved