1. Install the Sybase client on the server and configure dsedit, for example:
2. Configure the ODBC system DSN, for example:
3. source code example:
The following is a code snippet:
The following is a code snippet: Public xmldocument riverxml () // log Library { // Define the ODBC Data Source of the log Library String strodbcconnection_logdb = "driver = {sybase system 11}; srvr = jdtmdb; uid = sa; Pwd =; DB =Logdb"; // Logdb is the database name Odbcconnection ologconn; Odbccommand ologcmd; Xmldocument Doc; Xmltextwriter xtw; String lchtml; String strdbreturnstring; Odbcdatareader mylogdatareader = NULL; String stcd; String stna = ""; String strsql; Strsql = "select * From TV _river_t order by ymdhm DESC ";
// St_dam_r Strdbreturnstring = ""; Ologconn = new odbcconnection (strodbcconnection_logdb ); Ologcmd = new odbccommand (strsql, ologconn ); Ologconn. open (); Mylogdatareader = ologcmd. executereader (commandbehavior. closeconnection ); While (mylogdatareader. Read ()) { Stcd = mylogdatareader ["stcd"]. tostring (); If (stcd = "53049") stna = "Shao Bo water station "; If (stcd = "53071") stna = "Xinghua "; Strdbreturnstring + = "<Rows>" + "<Cols>" + stcd + "</Cols>" + "<Cols>" + stna + "</Cols>" + "<Cols>" + datetime. parse (mylogdatareader ["ymdhm"]. tostring ()). tostring ("yyyy-mm-dd hh: mm") + "</Cols>" + "<Cols>" + mylogdatareader ["ZR"]. tostring () + "</Cols>" + "<Cols>" + mylogdatareader ["Q"]. tostring () + "</Cols>" + "<Cols>" + mylogdatareader ["xsa"]. tostring () + "</Cols>" + "<Cols>" + mylogdatareader ["zrtend"]. tostring () + "</Cols>" + "<Cols>" + mylogdatareader ["qmes"]. tostring () + "</Cols>" + "</Rows> "; Stna = ""; } Mylogdatareader. Close (); Ologconn. Close (); //... The following section is omitted... } |
|
|