When I knocked on the student information management system, I found a problem. In fact, this problem should be summarized during the five examples, but it was also confused and hard to understand. Now I finally understand it.
In the student information management system, the connection statement with SQL Server is:
Connectstring = "filedsn = maid. DSN; uid = sa; Pwd = 123456" connectstring = "provider = sqloledb; server = 192.168.24.140; uid = sa; Pwd = 123456; database = student"
Connectstring = "filedsn = studentinfo. DSN ;"
In the first statement, when connecting VB to the database, you need to create a file DSN as follows:
Open Control Panel-Administrative Tools-Data Source (ODBC)-file DSN-add.
One step
If you enter the logon ID and password for SQL Server Authentication. The connection statement should be:
Connectstring = "provider = sqloledb; server = 192.168.24.140; uid = SAS; Pwd = 123456; database = student"
If the window of the network login ID is used, the connection statement is:
Connectstring = "filedsn = studentinfo. DSN ;"
Of course, VB and SQL server can also be remotely connected. In this process, you do not need to create an ODBC data source, which is identified by IP address. The connection statement is:
Connectstring = "provider = sqloledb; server = 192.168.24.140 (this is an IP address); uid = sa; Pwd = 123456; database = student (Database Name )"
In this way, when you use a LAN, you can also connect to the peer database through this method, which is easy to manage.