Create a DSN using VFP to effectively use Connection Sharing and connection handle

Source: Internet
Author: User
Tags dsn

This COM is used to call the API function and create a DSN. The input parameters are valid IP addresses or network hosts.
# Define odbc_add_dsn 1
# Define odbc_config_dsn 2
# Define odbc_remove_dsn 3
Define class createdsn as session olepublic
Datasession = 2
Procedure IPaddress (cipaddress as string)
Cipcoding = strconv (cipaddress, 13)
Cipdcoding = strconv (cipcoding, 14)
Declare integer sqlconfigdatasource in odbccp32 integer nhandleparent, integer frequest, string cdatadriver, string lpszattributes
Cdatadriver = 'SQL Server'
Cdataattributes = "Server =" + alltrim (cipdcoding) + CHR (0) + "Description = datadsn" + CHR (0) + "DSN = linkdatadsn" + CHR (0) + "database =" + alltrim ('finacialdatabase ')
Nhandleparent = NULL
Nreturn = sqlconfigdatasource (0, odbc_config_dsn, cdatadriver, cdataattributes)
If nreturn = 0
Mreturn = sqlconfigdatasource (0, odbc_add_dsn, cdatadriver, cdataattributes)
If mreturn = 0
Clear DLLs
Endif
Else
Clear DLLs
Endif
Endproc
Procedure error (nerror as integer, cmethod as string, nline as integer)
Local ctext as string
Ctext =;
'Error time: '+ transform (datetime () + Cl +;
'Error code: '+ STR (nerror, 4) + Cl +;
'Error message: '+ message () + Cl +;
'Error method: '+ cmethod + Cl +;
'Error row number: '+ transform (nline) + Cl
Strtofile (ctext, 'c:/powerfox.txt ',. T .)
Comreturnerror ("powerfox COM Service", ctext)
Endproc
Enddefine

 

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.