C # generate a specified format for the results of copying PL/SQL query result Columns

Source: Internet
Author: User

For example, the results of an SQL query in PL/SQL are as follows:

Leaf

Wei

Hong

Sun

He

... Is omitted later

To generate the dictionary format:

{1, "Ye" },{ 2, "wei" },{ 3, "Hong" },{ 4, "Sun" },{ 5, "He "}...

First, copy the columns of PL/SQL, put them in a string, and cycle the char of this string. Because the string contains a line break, we need to judge and remove it in the loop and then perform processing.

The Code is as follows:

Private void button#click (object sender, EventArgs e)

{

String s = @"

Leaf

Wei

Hong

Sun

He

"; // Unspecified...

String result = "", r = "";

Int I = 1;

Foreach (char c in s)

{

R = c. ToString (). Replace ('R', ''). Replace ('n ','');

If (r! = "")

{

Result + = "{" + I. ToString () + @ "," + r + @"""},";

I ++;

}

}

Result = result. TrimEnd (',');

TextBox1.AppendText (result );

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.