本文介绍了索引(基于零)必须大于或等于零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我不断收到一个错误:
My code:
OdbcCommand cmd = new OdbcCommand("SELECT FirstName, SecondName, Aboutme FROM User WHERE UserID=1", cn);
OdbcDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Name.Text = String.Format("{0} {1}", reader.GetString(0), reader.GetString(1));
Aboutme.Text = String.Format("{2}", reader.GetString(0));
}
解决方案
Your second String.Format
uses {2}
as a placeholder but you're only passing in one argument, so you should use {0}
instead.
Change this:
String.Format("{2}", reader.GetString(0));
To this:
String.Format("{0}", reader.GetString(2));
这篇关于索引(基于零)必须大于或等于零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!