IDC billing system summary (data connection and query)

Source: Internet
Author: User
IDC billing system summary (data connection and query)

The data connection process of the charging system in the data room is to first establish a connection between the ODBC drive and the backend database server, then use the code to establish a connection with ODBC, and then use the code to operate the data on the database server through ODBC, the connection code is as follows:

Public Function connectstring () as string 'establish a remote server data connection connectstring = "provider = sqloledb; Data Source = 192.168.24.176; initial catalog = computerroomcharge_sys; uid = sa; pwd = 123456 "'connectstring =" filedsn = computercharge. DSN; uid = sa; Pwd = 123456 "here is to establish a local data connection end functionpublic function executesql (byval SQL as string) as ADODB. recordset dim ojbcnn as connection dim objrst as recordset dim arry () as string on error goto executesql_error arry () = Split (SQL) set objcnn = new connection objcnn. open connectstring 'determines whether it is not a query statement if instr ("delete, insert, update", ucase (arry (0) Then objcnn. execute SQL msgbox "operation successful", vbokonly + vbexclamation, "prompt" else set objrst = new recordset objrst. open trim (SQL), objcnn, adopenkeyset, adlockoptimistic set executesql = objrst end if 'error handling statement executesql_exit: Set objrst = nothing set objcnn = nothing exit function executesql_error: msgbox "database query error", vbokonly + vbexclamation, "prompt" resume executesql_exit

 

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.