我有一个 sql 查询,它从 SQLdatabase 检索信息,我需要为发送给客户端的每个批次添加前导和尾随。我已经搜索过,但不走运。标题记录应该有 Recordtype(1)CPC 编号 (0000) 文件序列号 (001) 并且尾部记录应该有记录类型 (1) 请求总数 (5)、总诉讼费 ()、总索赔金额 ()。
string stringSql1 = " SELECT distinct " +
"'" + comboBox6.Text + "' as Recordtype" +
",'" + textBox5.Text + "' as Recordtype" +
" , space(1983) ";
string stringSql = " SELECT distinct " +
"'" + comboBox6.Text + "' as RecordType" +
" , left([Claimant Name] +' ',30) " +
" , left([Claimant Address1] +' ',30) " +
" , left([Claimant Address2] +' ',30) as ClaimantAddress2 " +
" , left([Claimant Address3] +' ',30) as ClaimantAddress3 " +
" , left([Claimant Address4] +' ',30) as ClaimantAddress4 " +
string whereClause = "";
===so on ....==================================
string[] tempArray = new string[this.txt.Lines.Length];
tempArray = this.txt.Lines;
if (this.txt.Lines.Length == 0)
{
return;
}
for (int counter = 0; counter <= tempArray.Length-1; counter++)
{
if (tempArray[counter].Trim().Length > 0)
{
whereClause = whereClause + "'" + tempArray[counter] + "'" + ", ";
}
}
whereClause = whereClause.TrimEnd(' ', ',');
whereClause = "(" + whereClause + ")";
stringSql = stringSql.Replace("{where}", whereClause);
myDataset = new DataSet("SQL");
SqlConnection myConn = new SqlConnection();
SqlCommand myCommand = new SqlCommand();
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = stringSql;
myCommand.Connection = myConn;
SqlDataAdapter myAdapter = new SqlDataAdapter();
myAdapter.SelectCommand = myCommand;
myAdapter.Fill(myDataset);