Database transaction connection, before very little contact, do things are using the local database, not used remote, database transaction connection is also using the default, so it caused the basic knowledge of the lack of understanding, is actually very simple things.
First you have to set up the database over there, ODBC or OLE db or, in short, the data source to build up first. And then just a few things about the code in the program:
SQLCA. DBMS = "OLE DB"
SQLCA. Logid = Gs_logid
SQLCA. Logpass=gs_logpass
SQLCA. Autocommit = False
Sqlca.dbparm = "provider= ' SQLOLEDB ', datasource= '" +gs_datasource+ "', timeout=" +string (ltime) + ", providerstring= ' Database= "+gs_database+" "
The first line is the name of the data manufacturer, which is plainly the way you connect. Then these variables are required: Gs_logid user name, Gs_logpass password (nullable), Gs_datasource data source, Gs_database database. The value of timeout is the time to set up the connection database. Assign these variables, and then use the statement connect using SQLCA can be practiced to the database, whether remote or local, the database will be automatically to you, but the database connection is very resource-intensive, if you do not open the database or network interruption, it is likely to cause the machine is very card.
That day also compiled a test program, is connected to a remote database, if disconnected on the count of +1, very simple one thing, done several times. is actually a timer () event, let the database constantly judge the connection.
W_testing.setfocus ()
int Lcount
Select COUNT (1) Into:lcount from Sys_user using Sqlca;
If sqlca.sqlcode= 0 Then
st_4.text= "Connected"
Ib_lastconnect=true
Else
If Ib_lastconnect=true Then
gl_counter++
Sle_1.text=string (Gl_counter)
W_main.sle_1.text=string (Gl_counter)
End If
Ib_lastconnect=false
St_4.text= "Disconnected, trying to reconnect"
SQLCA. DBMS = "OLE DB"
SQLCA. Logid = Gs_logid
SQLCA. Logpass=gs_logpass
SQLCA. Autocommit =true
Sqlca.dbparm = "provider= ' SQLOLEDB ', datasource= '" +gs_datasource+ "', timeout=15,providerstring= ' database=" +gs_ Database+ "'"
Disconnect using Sqlca;
Connect using Sqlca;
End If