日期:2014-05-18  浏览次数:20535 次

System.FormatException: 索引(从零开始)必须大于或等于零,且小于参数列表的大小
string sql = string.Format("insert into Student (name,address,tele,email,sex,grade,class) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}'),name,adress,tele,email,sex,grade,class14");
哪里错了?

------解决方案--------------------
string sql = string.Format("insert into Student (name,address,tele,email,sex,grade,class) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')“,name,adress,tele,email,sex,grade,class14);

最后“放错位置了
------解决方案--------------------
string sql = string.Format("insert into Student (name,address,tele,email,sex,grade,class) values({0},{1},{2},{3},{4},{5},{6})","name","adress","tele","email","sex","grade","class14");
------解决方案--------------------
string sql = string.Format("insert into Student (name,address,tele,email,sex,grade,class) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",name,adress,tele,email,sex,grade,class14);

------解决方案--------------------
string sql = string.Format("insert into Student (name,address,tele,email,sex,grade,class) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",name,adress,tele,email,sex,grade,class14);