zoukankan      html  css  js  c++  java
  • 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";

  • 相关阅读:
    Jmeter跨线程组传值
    python基础之高级函数
    Python基础之函数的应用
    python基础之文件的输入输出
    python基础练习之猜数字
    折腾了两天的跨站脚本提交问题,与IIS7有关
    python简介和环境搭建
    python paramiko
    Linux rsync 企业级应用
    Linux find 命令详解
  • 原文地址:https://www.cnblogs.com/smartsmile/p/6234444.html
Copyright © 2011-2022 走看看