SQL::ConnectionSetConnectionString Method
Syntax
Arguments
- SQLConnectionStringCharacter
A string that contains the parameters required to locate the database, identify the target table, and establish a connection to it. The connect string can be in one of the following formats:
- Format 1 - {name1='value1',name2='value2'...nameN='valueN'}
- Format 2 - name1value1 name2value2 ...nameNvalueN
- A named connection string. E.g. "::Name::AADemo-Northwind"
Returns
- Result_FlagLogical
TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).
Description
Set the connection string with required parameters. The actual values will depend on how you are connecting to your database.
Discussion
The SetConnectionString() method sets the connection string with required parameters. The actual values will depend on how you are connecting to your database.
Example
The connect string can be in one of two formats: Format 1 {name1='value1',name2='value2'...nameN='valueN'} Example:
connectstring = "{UserName='Fred',Password='secret'}" myconn.SetConnectionString(connectstring)
Another example using Format 1
dim conn as SQL::Connection dim cs as C cs = "{A5API=Access,FileName='C:\Program Files\A5V8\MDBFiles\Alphasports.mdb',UserName='Admin'}" if .not. conn.open(cs) then ui_msg_box("Error", conn.CallResult.text) end end if if .not. conn.SetConnectionString(cs) then ui_msg_box("Error", conn.CallResult.text) end if conn.close()
Format 2, name1<tab>value1<crlf> for each entry: Example:
connectstring = "UserName" + chr(9) + "Fred" + crlf() connectstring = connectstring + "Password" + chr(9) + "secret" + crlf() myconn.SetConnectionString(connectstring)
Another example using Format 2
dim conn as SQL::Connection dim cs as C cs = "A5API" + chr(9) + "Access" + crlf()+ "FileName" + chr(9) + "C:\Program Files\A5V8\MDBFiles\Alphasports.mdb" + crlf()+ "UserName" + chr(9) + "Admin" if .not. conn.open(cs) then ui_msg_box("Error", conn.CallResult.text) end end if if .not. conn.SetConnectionString(cs) then ui_msg_box("Error", conn.CallResult.text) end if conn.close()
See Also