テキストファイルからグローバルパラメーターを読み取り、データベースからcsvファイルにデータをエクスポートできる.exeファイルを作成しようとしています
基本的に、接続文字列を読み取ってテキスト ファイルからコマンドを読み取ることはできますが、csv ファイルを作成することはできません。
私のコードは以下のようなものです
static class CsvGenerator
{
public static string gb_Localconn = DBManager.GetParameter("ConnStr=");
public static string gb_Delimiter = DBManager.GetParameter("Delimiter=");
public static string gb_Quote = DBManager.GetParameter("Quote=");
public static string gb_QuoteType = DBManager.GetParameter("Quote_Type=");
public static string gb_CsvOutput = DBManager.GetParameter("Output_path=");
public static string gb_Prefix = DBManager.GetParameter("Output_Prefix=");
public static string gb_LogOutput = DBManager.GetParameter("Logfile_path=");
public static string gb_VesselList = DBManager.GetParameter("Vessel_list=");
private static DataTable dt;
private static int i;
public static void Main()
{
StreamReader oRead = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "Query.cfg");
string txtline = null;
string QueryName = null;
string query = null;
while (oRead.Peek() != -1)
try
{
txtline = oRead.ReadLine();
if (txtline.IndexOf(":") != -1)
{
QueryName = txtline.Substring(0, txtline.IndexOf(":"));
query = txtline.Substring(txtline.IndexOf(":") + 1, txtline.Length - QueryName.Length - 1);
query = query.Replace("|Vessels|", gb_VesselList);
MessageBox.Show(query);
{
{
dt = DBManager.DBExecuteSelect(query, gb_Localconn);
DataColumn dcol = null;
if (dt.Rows.Count > 0)
MessageBox.Show(dcol.ToString());
}
DataRow drow = null;
for (i = 0; i <= dt.Rows.Count - 1; i++)
MessageBox.Show(drow.ToString());
}
}
}
catch (InvalidCastException e)
{
Console.WriteLine("{0} Exception caught.", e);
{
}
}
}
}
誰かがこれで私を助けることができますか?