C# 如何修复';当我编写用于搜索的存储过程时';?
我正在编写一个用于搜索多个记录的存储过程,没有任何错误,但问题是当我搜索一个记录并需要在搜索给我这个异常后更新此记录时,当我不搜索而转到记录时,我可以更新它。这是C#中的问题还是存储过程中的问题C# 如何修复';当我编写用于搜索的存储过程时';?,c#,sql-server,C#,Sql Server,我正在编写一个用于搜索多个记录的存储过程,没有任何错误,但问题是当我搜索一个记录并需要在搜索给我这个异常后更新此记录时,当我不搜索而转到记录时,我可以更新它。这是C#中的问题还是存储过程中的问题 private void button2_Click(object sender, EventArgs e) { frm.dtpCheck.Text = this.dataGridView1.CurrentRow.Cells[9].Value.ToString(); frm.dtpnextCh
private void button2_Click(object sender, EventArgs e)
{
frm.dtpCheck.Text = this.dataGridView1.CurrentRow.Cells[9].Value.ToString();
frm.dtpnextCheck.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString();
frm.txtIncomMoney.Text = this.dataGridView1.CurrentRow.Cells[11].Value.ToString();
frm.txtResMoney.Text = this.dataGridView1.CurrentRow.Cells[12].Value.ToString();
frm.txtfrom.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString();
frm.txtto.Text = this.dataGridView1.CurrentRow.Cells[14].Value.ToString();
frm.Text = "Update Patient" + this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
frm.btnOk.Text = "Update";
ALTER proc [dbo].[Search_Pa]
@ID nvarchar(50)
as
select * from tb_Patients
inner join tb_Rolls
on tb_Patients.RollID =tb_Rolls.RollID
where tb_Patients.PatientName+
tb_Patients.PatientAddress+
tb_Patients.PatientPhone
like '%'+@ID+'%'
param[7] = new SqlParameter("@dateofcheck", SqlDbType.DateTime2);
param[7].Value = DateOfCheck;
param[8] = new SqlParameter("@dateofnextcheck", SqlDbType.DateTime2);
param[8].Value = DateOfNextCheck;
param[9] = new SqlParameter("@residualmoney", SqlDbType.Decimal);
param[9].Value = ResidualMoney;
param[10] = new SqlParameter("@receivemoney", SqlDbType.Decimal);
param[10].Value = IncomingMoney;
param[11] = new SqlParameter("@firstcheck", SqlDbType.VarChar,10);
param[11].Value = FirstCeck;
param[12] = new SqlParameter("@endcheck", SqlDbType.VarChar,10);
param[12].Value = EndCheck;
param[13] = new SqlParameter("@ID", SqlDbType.Int);
param[13].Value = ID;
param[14] = new SqlParameter("@RID", SqlDbType.Int);
param[14].Value = RID;
dal.IUD("update_Patients", param);
dal.CloseCon();
}
mscorlib.dll中发生类型为“System.FormatException”的未处理异常
其他信息:单元格[9]中的字符串未被识别为有效的DateTime。)
显示的代码中没有一行与调用存储过程有关。我们应该如何修复我们看不到的内容?很抱歉,我在单元格数量上有一个错误。单元格[9]上的异常指出。如果您使用的是datetime选择器,您怎么会在datetime中使用无效字符串?与问题相关的代码应该在问题中,而不是注释中,@Anas。“FormatException”是一条.Net消息,不是SQL消息。所以这个错误在你的C代码中。显然,您正在尝试从字符串中创建日期时间值(当前代码中未显示)。那个字符串值是多少?您是如何尝试将其转换为日期时间的?请把这些细节纳入你的问题。