VB6 and ASP Production Management System 1-vb6 connection SQL2000

Source: Internet
Author: User

The main focus is on the Code. As long as you have done database design, there is basically no problem!

1. VB6-> create a program

Add reference

Project-> reference

Microsoft ActiveX Data Objects 2.8 libray (or another version)

Microsoft ActiveX Data Objects recordset 2.8 libray (or another version)

Create module myconn. bas for database connection)

Call to open a database connection

Call openconn

Close the database connection (RS is used in use, so it is written to the function together with RS)

Call closeconn

The myconn. Bas code is as follows:

1 'define data connection
2 Public conn as new ADODB. Connection
3' define a dataset
4 Public RS as new ADODB. recordset
5' Database Name
6 Public dataname as string
7'database host
8 Public hostip as string
9' User Name
10 public hostuser as string
11' Password
12 public hostpass as string
13 'database connection string
14 public cnstr as string
15
16 'database connection functions
17 '-------------------------------------------------
18 public sub openconn ()
19 'cnstr = "provider = msdatashape; data provider = msdasql; uid =" & dbuser & "; Pwd =" & dbpw & "; driver = SQL server; database = "& dbname &"; wsid = gqsoft; server = "& dbip
20 'conn. Open cnstr use the open method of the connection set to establish a connection with the database
21
22 hostip = "192.168.9.71"
23 hostuser = "sa"
24 hostpass = "bmschool"
25 dataname = "vehicle"
26 Conn. connectionstring = "driver = {SQL Server}; server =" & hostip & "; uid =" & hostuser & "; Pwd =" & hostpass &"; database = "& dataname &""
27 conn. Open
28 end sub
29' disable data
30 public sub closeconn ()
31 Rs. Close
32 set rs = nothing
33 conn. Close
34 set conn = nothing
35 end sub

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.