如何解决“当我编写用于搜索的存储过程时”?

时间:2019-09-16 14:24:03

标签: c# sql-server

我正在编写一个用于搜索许多记录的存储过程,没有什么错,但是问题是当我搜索一条记录并需要在搜索给我此异常后更新此记录时,而当我不进行搜索就进行记录时,我可以更新它。这是C#还是存储过程中的问题?

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。

0 个答案:

没有答案