日期:2014-05-18  浏览次数:20974 次

客户通过代理上网,winform 如何通过代理访问远程数据库
客户通过代理上网,winform 能通过webservices 访问远程数据库
  现在有大量数据导出到excel 通过 webservices 太慢了
  想用SqlConnection 导出

C# code
public static readonly string CONN_STRING = "Data Source=210.1.1.1;Initial Catalog=qq;Persist Security Info=True;User ID=dsh;Password=123456;"


.....
C# code

string strQuery = string.Empty;
            if (blIsMoreThan)
            {
                
    strQuery = "select top "+this.dbSheetSize +" "+strSql+" from "+ strTablName + " where ["+fldName+"] >(select max (["+ fldName + "]) from (select top " + dbSheetSize * (intSheetNumber - 1) + " ["+ strSql + "] from [" + strTablName + "] where 1=1 " + strWhere + " order by [" + fldName +"] asc "+ ") as tblTmp) and 1=1 " + @strWhere + " " + " order by [" + fldName +"] asc ";
            }
            else
            {
                
                strQuery = "select top " + this.dbSheetSize + strSql+"  from ["+ strTablName + "] where 1=1 " + strWhere + " "+"order by [" + fldName +"] asc ";

            }
            m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(intSheetNumber));

            m_objSheet.Cells[1,1] = strMastTitle;
            m_objSheet.Cells[2,1] = "打印日期"+DateTime.Now.ToShortDateString();
            for(int i = 1;i<=strTitle.Length;i++)
            {
                m_objSheet.Cells[4,i] = strTitle[i-1].ToString();
            }
            m_objRange = m_objSheet.get_Range("A5", m_objOpt);
            [color=#FF0000]m_objQryTable = m_objSheet.QueryTables.Add("OLEDB;Provider=SQLOLEDB.1;" + sqlConn.ConnectionString, m_objRange, strQuery);[/color]            m_objQryTable.RefreshStyle = Excel.XlCellInsertionMode.xlInsertEntireRows;
            m_objQryTable.FieldNames = false;
            m_objQryTable.Refresh(false);



本地导出没问题 客户那里没反映,怎么通过代理访问远程sqlserver? 谢谢

------解决方案--------------------
可以用压缩soap message的方式使用web service

如果你用wcf的话可以参考下面的文章: 
Custom Message Encoder: Compression Encoder 

http://msdn.microsoft.com/en-us/library/ms751458.aspx

不是WCF的话可以用WSE 
参考: 
http://weblogs.asp.net/pglavich/archive/2004/01/24/62475.aspx 
http://weblogs.shockbyte.com.ar/rodolfof/archive/2006/02/07/4585.aspx