当前位置: 代码迷 >> ASP.NET >> System.FormatException: 索引(从零开始)必须大于或等于零,且小于参数列表的大小,该如何解决
  详细解决方案

System.FormatException: 索引(从零开始)必须大于或等于零,且小于参数列表的大小,该如何解决

热度:2956   发布时间:2013-02-25 00:00:00.0
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);
  相关解决方案