0
using (OracleCommand crtCommand = new OracleCommand("myCommand", conn1))
{
     richTextBox1.AppendText(Environment.NewLine);
     richTextBox1.AppendText(crtCommand.ExecuteScalar().ToString() + ";");
     richTextBox1.AppendText(Environment.NewLine);
}

结果:

CREATE UNIQUE INDEX "XPKTBL_A" ON "TBL_A" ("FIELD_A1")
;

预期结果:

CREATE UNIQUE INDEX "XPKTBL_A" ON "TBL_A" ("FIELD_A1");
4

3 回答 3

0

@AndreasNiedermair 已经在评论中提出了建议,但修剪换行符应该会有所帮助

richTextBox1.AppendText(crtCommand.ExecuteScalar().ToString().TrimEnd('\r', '\n', ' ') + ";");
于 2013-07-24T08:27:18.540 回答
0

尝试以下

string g = crtCommand.ExecuteScalar().ToString() + ";";
richTextBox1.AppendText(g.Replace("\n", string.Empty));

代替

richTextBox1.AppendText(crtCommand.ExecuteScalar().ToString() + ";");
于 2013-07-24T08:26:20.633 回答
0

正如我已经在评论中提到的那样,只需将其添加为答案。

richTextBox1.AppendText(String.Format("{0};",crtCommand.ExecuteScalar().ToStrin‌​g()));
于 2013-07-24T08:29:18.500 回答