常用数据库连接字符串
连接ORACLE:<add key="ConnectionString" value="Data Source=YOURDATABASENAME;User ID=YOURID;Password=YOURPSW;Unicode=True"/>
连接SQLSEVER: <add name="ConnectionString" connectionString="server=your server database;uid=sa;pwd=your psw;database=databasename; Max Pool Size=100; Min Pool Size=8;" providerName="System.Data.SqlClient"/>
连接MySql:
using System;
using System.Net;
using System.Text;
using CoreLab.MySql;
using System.Data.Odbc;
using MySql.Data.MySqlClient;
class ConnectMySql
{
public void Connect_CoreLab()
{
string constr = "User Id=root;Host=localhost;Database=qing;password=qing";
MySqlConnection mycn = new MySqlConnection(constr);
mycn.Open();
MySqlCommand mycm = new MySqlCommand("select * from shop",mycn);
MySqlDataReader msdr = mycm.ExecuteReader();
while(msdr.Read())
{
if (msdr.HasRows)
{
Console.WriteLine(msdr.GetString(0));
}
}
msdr.Close();
mycn.Close();
}
}