欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

字符串转SQL in C#

程序员文章站 2022-07-16 21:26:26
...

字符串转SQL in C#

            string[] striparr = richTextBox1.Text.Split(new string[] { "\n" }, StringSplitOptions.None);
            striparr = striparr.Where(s => !string.IsNullOrEmpty(s)).ToArray();
            for (int i = 0; i < striparr.Length; i++)
            {
                if (i == 0)
                {
                    richTextBox2.Text = " in ('" + striparr[i].Replace("	", "'\n,'");
                }
                else if (i == striparr.Length - 1)
                {
                    richTextBox2.Text = richTextBox2.Text + striparr[i].Replace("	", "") + "')";
                }
                else
                {
                    richTextBox2.Text = richTextBox2.Text + striparr[i].Replace("	", "") + "'\n,'";
                }
            }
            Clipboard.SetText(richTextBox2.Text);