1.在服务器上安装Sybase客户端,配置Dsedit,如下图:
![](http://www.18839.com/Edu/UploadPic/2006-2/2006228133851358.jpg)
2.配置ODBC的系统DSN,如下图:
![](http://www.18839.com/Edu/UploadPic/2006-2/2006228133852919.jpg)
3.源代码示例:
以下是代码片段:
以下是代码片段: public XmlDocument RiverXml() //Log库 { //定义LOG库的ODBC数据源 string strODBCConnection_LogDB = "Driver={SYBASE SYSTEM 11};Srvr=jdtmdb;Uid=sa;Pwd=;DB=logdb"; // logdb 是数据库名称 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 = "邵伯水位站"; if (STCD == "53071") STNA = "兴化"; 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();
// .... 以下部分略... }
|
|
|