0

我正在尝试将文本框中的多行值保存到 sql 中的多行中。我有一个如下图所示的文本框

http://www.4shared.com/photo/91DD7knd/Multi-textbox.html

保存后,我想在数据 sql 中如下:

http://www.4shared.com/photo/8yEVRPbV/Data-Sql.html

4

1 回答 1

0

试试这个方法,这一次插入三行作为逗号分隔值

public void insertRowsToDb(string multiTextString)
{
    int i = 0;
    string insertString = "";
    string[] result = multiTextString.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
    foreach (string s in result)
    {
        for (i = 0; i = 2; i++)
        {
            insertString = insertString + s+",";
            //Console.WriteLine(s);
        }
        insertString = insertString.Substring(0, insertString .Length - 1);//Trim last comma
        insertToDb(insertString);//Your DB insert procedure here
        i = 0;
    }
}
于 2012-11-19T04:51:35.507 回答