首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-04-18 
System.FormatException: 索引(从零开始)必须大于或等于零,且小于参数列表的大小string sql string.Form

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);

热点排行