目的: V80202H - QDR資料查詢 -直接連 SQLServer資料庫,顯示資料
處理說明: 1>connectionString - web.config
<add name="QDR_IDF" connectionString="Data Source=194.1.5.222;
Initial Catalog=qdr_idf;User ID=ammuser;Password=useramm; " />
<add name="QDR_TP" connectionString="Data Source=192.30.15.129;
Initial Catalog=task_planning;User ID=ammuser;Password=useramm; " />
2>取得 SQLServer ds : - getDataTable_MSSQL(dblink,Tmp_Sql);
- SQLServer - From ( ) A2 - 必需有名稱(xx) , 否則 SQL 會錯
string Tmp_Sql = " SELECT RNK,project_code, sor_no , "
+ " FROM (SELECT dense_rank() over( order by sor_no,ref_document ) as RNK,"
+ " project_code, sor_no , "
+ " FROM AMM_VIEW "
+ " WHERE 1=1 ";
if (!myfunc.checkisnull(Tmp_SAPNO))
{
Tmp_Sql = Tmp_Sql + " AND ref_document = " + myfunc.AA(Tmp_SAPNO);
}
Tmp_Sql = Tmp_Sql + ") A2";
cmd.CommandText = Tmp_Sql;
string countSql = " SELECT COUNT(*) as total FROM (" + Tmp_Sql + ") C2";
//public dynamic getDataTable_MSSQL(string iDBLINK, string sql, string countSQL = "",)
DataSet ds = getDataTable_MSSQL("QDR_TP", Tmp_Sql, countSql);
return ds;
沒有留言:
張貼留言