代碼如下,求幫忙
namespace LDD__Generator
{
public partial class LDD : Form
{
public LDD()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
GetData();
}
private void GetData()
{
try
{
DataTable dtMAT_NR = SQLUtility.Select("Select MAT_NR From ADE_LOS Where LOS_NR = '" + txtLOS_NR.Text.Trim() + "'", null);
DataTable dtPANELID = SQLUtility.Select("Select PANELID From FCBDB.dbo.PANELTAB Where LOSID ='" + txtLOS_NR.Text.Trim() + "'", null);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
private void txtLOS_NR_KeyPress(object sender, KeyPressEventArgs e)
{
GetData();
}
}
這個是需要的結果圖
求指教怎麼寫
private void GetData()
{
try
{
DataTable dtMAT_NR = SQLUtility.Select("Select MAT_NR From ADE_LOS Where LOS_NR = '" + txtLOS_NR.Text.Trim() + "'", null);
DataTable dtPANELID = SQLUtility.Select("Select PANELID From FCBDB.dbo.PANELTAB Where LOSID ='" + txtLOS_NR.Text.Trim() + "'", null);
//遍歷2個表格組合好字符串調用IO寫入記事本不就好了
string s="";
foreach (DataRow dr in dtMAT_NR) s += "MAT_NR=" + dr[0].ToString() + "\r\n";
foreach (DataRow dr in dtPANELID) s += "PAN=" + dr[0].ToString() + "\r\n";
//記得修改第一個參數為你需要制定的位置
System.IO.File.WriteAllText(@"c:\xxx.txt",s,System.Text.Encoding.UTF8);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}