There are already many examples of using VB to connect to the database over the past few days. It is estimated that the most difficult thing to do is to write the connectionstring string. This attribute is very important, A Property contains several small attributes, which are not easy to write completely. I often paste the previously written attributes.
Below we will summarize the common attributes of this string:
(1). Use the SQL Server database connection string (the yellow strip is the parameter that must be set to use remote connection)
SQL connection to database |
Attribute |
Function |
Example |
Provider |
Database driver |
Provider = sqloledb.1 |
Integrated Security |
Set whether to use system integration verification during logon |
Integrated Security = sspi |
Persist Security info |
Set whether to save Security Information (Save Password, etc) |
Persist Security info = false |
Initial catalog |
Database Name |
Initial catalog = instance 1 |
Data Source |
If remote access is not used (only local access is used), do not write the data source = (local) |
Data Source = XDP-PC or data source = 192.168.24.144 |
User ID |
User ID used to connect to the database |
User ID = sa |
Password |
Database connection password |
Password = 123456 |
(2). Use the Access database to connect to a string
Access Database |
Attribute |
Function |
Example |
Provider |
Database driver |
Provider = Microsoft. Jet. oledb.3.51 or 4.0 |
Data Source |
Database source, which is generally a physical path |
Data Source = & App. Path & "\ instance 1.mdb" |
(3). Use ODBC to connect to a string
ODBC |
Attribute |
Function |
Example |
DSN |
Set the created DSN (user, system, and file) |
DSN = instance 2dsn |
These hopes are helpful to everyone.