C#版mysql连接字符串
1. ODBC DSN
2. ODBC -- MyODBC Driver -- local database
3. ODBC -- MyODBC Driver -- remote database
4. ODBC -- MySQL ODBC 3.51 Driver
5. OleDb
6. .NET DataProvider from CoreLab
1. // ODBC DSN
2.
3. using System.Data.Odbc;
4.
5. OdbcConnection conn = new OdbcConnection();
6. conn.ConnectionString =
7. "Dsn=DsnName;" +
8. "Uid=UserName;" +
9. "Pwd=Secret;";
10. conn.Open();
1. // ODBC -- MyODBC Driver -- local database
2.
3. using System.Data.Odbc;
4.
5. OdbcConnection conn = new OdbcConnection();
6. conn.ConnectionString =
7. "Driver={MySql};" +
8. "Server=localhost;" +
9. "Option=16834;" +
10. "DataBase=DataBaseName;"
11. conn.Open();
1. // ODBC -- MyODBC Driver -- remote database
2.
3. using System.Data.Odbc;
4.
5. OdbcConnection conn = new OdbcConnection();
6. conn.ConnectionString =
7. "Driver={MySql};" +
8. "Server=db.domain;" +
9. "Option=131072;" +
10. "Port=3306;" +
11. "Stmt=;" +
12. "DataBase=DataBaseName;" +
13. "Uid=UserName;" +
14. "Pwd=Secret;"
15. conn.Open();
1. // ODBC -- MySQL ODBC 3.51 Driver
2.
3. using System.Data.Odbc;
4.
5. OdbcConnection conn = new OdbcConnection();
6. conn.ConnectionString =
7. "Driver={MySql ODBC 3.51 Driver};" +
8. "Server=ServerName;" +
9. "Option=16834;" +mysql下载odbc失败
10. "Port=3306;" +
11. "Stmt=;" +
12. "DataBase=DataBaseName;" +
13. "Uid=UserName;" +
14. "Pwd=Secret;"
15. conn.Open();
16.
17. // or
18.
19. using System.Data.Odbc;
20.
21. OdbcConnection conn = new OdbcConnection();
22. conn.ConnectionString =
23. "DRIVER={MySql ODBC 3.51 Driver};" +
24. "SERVER=ServerName;" +
25. "DATABASE=DataBaseName;" +
26. "USER=UrerName;" +
27. "PASSWORD=Secret;"
28. conn.Open();
1. // OleDb
2.
3. using System.Data.OleDb;
4.
5. OleDbConnection conn = new OleDbConnection();
6. conn.ConnectionString =
7. "Provider=MySqlProv;" +
8. "Data Source=ServerName;" +
9. "User id=UserName;" +
10. "Password=Secret;"
11. conn.Open();
1. // .NET DataProvider from CoreLab
2.
3.
4. using CoreLab.MySql;
5.
6. MySqlConnection conn = new MySqlConnection();
7. conn.ConnectionString =
8. "Host=ServerName;" +
9. "DataBase=DataBaseName;" +
10. "Protocol=TCP;" +
11. "Port=3306;" +
12. "Direct=true;" +
13. "Compress=false;" +
14. "Pooling=true;" +
15. "Min Pool Size=0;" +
16. "Max Pool Size=100;" +
17. "Connection Lifetime=0;" +
18. "User id=UserName;" +
19. "Password=Secret;" +
20. conn.Open();
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论