VB6,C#连Sql server,Mysql,sqlite,access等数据库的连接字符串

时间:2022-02-21 04:24:23

(1), VB6 连 Sql Server

Provider=SQLOLEDB.1;Password=Pwd;Persist Security Info=True;User ID=UserName;Initial Catalog=DataBase_Name;Data Source=IP_Address

(2), C#连 Sql Server

           1,Windows验证               Common.ConnString = @"Initial Catalog=数据库名;Data Source=电脑名或IP地址;Integrated Security=SSPI";

           2, Sql混合验证                Common.ConnString = @"server=电脑名或IP地址;database=数据库名;uid=用户名;password=密码";


(3),C#连MySql

                  MySqlHelper.ConnString = string.Format(@"server={0};database={1};userid={2};password={3}"
    , txtServer.Text, txtDBName.Text, txtUid.Text, txtPwd.Text);

(4),C#连sqlite

           string.Format(@"Data Source={0}", ConnSqlLiteDbPath);    //ConnSqlLiteDbPath 为 **.db文件的具体路径

(5),C#连access

            string sDB_Path = Application.StartupPath.Replace(@"\bin\Debug", "") + @"\Data\#test.mdb";
            //JonseTool.AccessHelper.ConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sDB_Path + @";Persist Security Info=false;User Id=admin;Password=";
            JonseTool.AccessHelper.ConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sDB_Path + @";";

------------------------------------------------------------------------------------------------------