foreach (DataRow oRow in DT.Rows)
{
var oSP = new DB.StorePointRecord(oRow);
:
:
}
var oSP = new DB.StorePointRecord();
foreach (DataRow oRow in DT.Rows)
{
oSP.row = oRow;
:
:
}
public static DataTable DTFromSQL(string Sql, string DBC = null, Int32 timeout = 0)
{
SqlDataAdapter DA = new SqlDataAdapter(Sql, GetDBC(DBC));
DataTable DT = new DataTable();
try
{
DA = new SqlDataAdapter(Sql, DBC);
if (timeout > 0)
{
DA.SelectCommand.CommandTimeout = timeout;
}
DA.Fill(DT);
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
finally
{
DA.Dispose();
}
return DT;
}
public static DataTable DTFromSQL(string Sql, string DBC = null, Int32 timeout = 30)
{
using (var DA = new SqlDataAdapter(Sql, GetDBC(DBC)))
{
//不可為 null
DataTable DT = new DataTable();
DA.SelectCommand.CommandTimeout = timeout;
DA.Fill(DT);
return DT;
}
}
public static void WriteText1(string FileName, List<string> ltData)
{
foreach(string data in ltData)
{
System.IO.File.AppendAllText(FileName, data);
}
}
public static void WriteText2(string FileName, List<string> ltData)
{
var Res = "";
foreach (string data in ltData)
{
Res += data;
}
System.IO.File.WriteAllText(FileName, Res);
}
WITH [員工資料表new] AS (
--找出 [主管] 為 某人的資料當作 依據
SELECT [主管], [員工]
FROM [員工資料表]
WHERE [主管] = 'XXXX'
UNION ALL
--之後以 上面查出的結果 為依據遞迴查詢
SELECT e.[主管], e.[員工]
FROM [員工資料表] e
INNER JOIN [員工資料表new] ecte ON ecte.[員工] = e.[主管]
)
SELECT *
FROM [員工資料表new]