VBASP database connection string example

xiaoxiao2021-03-06  54

Use DSN's database connection character case:

MS SQL / MYSQL / PostgreSQL

"DSN = DSNNAME"

Unused DSN Database Connection Characters:

MS Access

Use OLEDB:

"Provider = microsoft.jet.Oledb.4.0; data source = c: somepathmydb.mdb;"

MS SQL

Use ODBC:

"Driver = {SQL Server}; server = myservername; database = mydatabaseename; uid = myusername; pwd = mypassword"

Use OLEDB (recommended):

"Provider = sqloledb; data source = myservername; initial catalog = myDatabaseName; user ID = myusername; password = mypassword

Mysql

Use ODBC:

"Driver = {mysql odbc 3.51 driver}; server = servername; database = dbname; uid = username; pwd = password; option = 3"

PostgreSQL

Use ODBC:

"Driver = {postgreSQL}; server = servername; database = dbname; uid = username; pwd = password"

For the MS Access database, because the ODBC driver of the Access database can cause unstable, it is best not to connect by DSN.

转载请注明原文地址:https://www.9cbs.com/read-116669.html

New Post(0)