if (PatnameTB.Text == "" || PatphoneTB.Text == " " ||
PatadressTB.Text == "" || PatdobTB.Text == "" ||
PatgenderCB.SelectedIndex == -1 || PatallergiesTB.Text == "" ||
PatmedhistoryTB.Text == "")
{
MessageBox.Show("Missing Data!!!");
}
else
{
string Name = PatnameTB.Text;
string Phone = PatphoneTB.Text;
string Address = PatadressTB.Text;
string Dateofbirth = PatdobTB.Text;
string Gender = PatgenderCB.SelectedItem.ToString();
string Allergies = PatallergiesTB.Text;
string Patmedhistory = PatmedhistoryTB.Text;
string Query = @"insert into Paitent.Tbl
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
Query = string.Format(Query, Name, Phone, Address, Dateofbirth,
Gender, Allergies, Patmedhistory);
Con.SetData(Query);
ShowPatients();
MessageBox.Show("Paitent Added!!");
}
當我嘗試為測驗目的添加新患者時,系統拒絕更新串列,但給我的索引(從零開始)必須大于或等于零且小于引數串列的大小。錯誤如果有人可以看看這個我會很高興
uj5u.com熱心網友回復:
錯誤訊息準確地告訴您出了什么問題:您的格式字串有 8 個插槽({0}
通過{7}
),但您只傳遞了 7 個引數。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/531191.html
標籤:C#