【发布时间】:2011-06-17 06:38:35
【问题描述】:
我的 Winforms 应用程序有一个 C# 列表:
List<string> StudentSubjects = new List<>(string);
我已将这些插入到列表中:
StudentSubjects.Add("Physics", "Chemistry", "Mathematics", "English");
现在我有一张桌子:STUDENTS
----------
**StudentID | SubjectsSelected**
---------
STDNT001 | [HERE all subjects selected by the student should be inserted]
STDNT002 | Physics, Chemistry, Mathematics, English
STDNT002 | Physics, Chemistry, Mathematics, English
----------
我应该为 MySql 使用 implode 函数吗?但是语法是什么?还有,要为 SQL Server 做什么。
我在做:
string query =
"INSERT INTO STUDENTS VALUES
('S001', implode('" + StudentSubjects.ToArray() + " ')) "
但是有一些错误。请帮忙。
【问题讨论】:
标签: c# .net mysql sql-server arrays