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