错误:最佳重载方法匹配'ClassData.Add(string, string, int, int, obje
本文关键字:int string ClassData Add obje 重载 最佳 方法 错误 | 更新日期: 2023-09-27 17:50:49
我下面有以下错误,我不知道我在这缺少什么,或者我必须为它安装指令。错误是
1. Cannot implicitly convert type 'System.Data.SqlDbType' to 'int'. An explicit conversion exists (are you missing a cast?).
2. cannot convert from 'System.Data.SqlDbType' to 'int'.
3. The best overloaded method match for 'ClassData.Add(string, string, int, int, object)' has some invalid arguments.
4. The best overloaded method match for 'ClassData.AddNText(string, string, int, int, System.Text.StringBuilder)' has some invalid arguments.
提前感谢您的帮助。
public bool SaveToDatabase(string mSpname)
{
bool rtVal = false;
try
{
string Proc_Code = this.ForStatus_Update != 0 ? string.Empty : this.mClsOBR.ListOBR[0].Proc_Code;
int Type_Code = this.ForStatus_Update != 0 ? 0 : this.mClsOBR.ListOBR[0].Type_Code;
clsDs = new classDataSource();
clsDs.Add(mSpname.Trim(), "@pWinBookid", SqlDbType.Int, 4, this.Winbookid);
clsDs.Add("", "@pNMRNO", SqlDbType.NVarChar, 10, this.NMRNO);
clsDs.Add("", "@Proc_Code", SqlDbType.NVarChar, 7, Proc_Code);
clsDs.Add("", "@Type_Code", SqlDbType.Int, 4, Type_Code);
//MsgBox(String.Concat("Proce :", Me.mClsOBR.ListOBR(0).Proc_Code, " Type Code:", Me.mClsOBR.ListOBR(0).Type_Code.ToString))
StringBuilder sb = GetStreamBulderHL7(this.dtMessage);
writeMessage(sb.ToString(), true);
clsDs.AddNText("", "@pHL7Results", SqlDbType.NText, sb.Length, sb);
clsDs.Add("", "@ImgItemID", SqlDbType.Int, 4, 0);
clsDs.Add("", "@PatStausUpdate", SqlDbType.Int, 4, this.ForStatus_Update);
writeMessage(string.Concat("Winbookid :", this.Winbookid, " NMRNO:", this.NMRNO), true);
writeMessage(string.Concat("Proce :", Proc_Code, " Type Code:", Type_Code.ToString()), true);
//srDr = clsDs.GetRs("ConnMedicalLab", 0)
using (SqlDataReader srDr = clsDs.GetRs("IMAGEDB", 0))
{
}
rtVal = true;
}
catch (Exception ex)
{
writeMessage(string.Concat(ex.Source, "Error :", ex.Message));
ModuleHl7.WriteExeptionLog(ex, "Problem in Saving to SQL - Called From: SaveToDatabase_Success");
rtVal = false;
}
return rtVal;
}
从错误信息中可以很清楚地看出第三个参数类型是int,而不是SqlDBType
clsDs.Add(mSpname.Trim(), "@pWinBookid", SqlDbType.Int, 4, this.Winbookid);
clsDs.Add("", "@pNMRNO", SqlDbType.NVarChar, 10, this.NMRNO);
clsDs.Add("", "@Proc_Code", SqlDbType.NVarChar, 7, Proc_Code);
clsDs.Add("", "@Type_Code", SqlDbType.Int, 4, Type_Code);
应为
clsDs.Add(mSpname.Trim(), "@pWinBookid", Some_Int_Value_Here, 4, this.Winbookid);
clsDs.Add("", "@pNMRNO", Some_Int_Value_Here, 10, this.NMRNO);
clsDs.Add("", "@Proc_Code", Some_Int_Value_Here, 7, Proc_Code);
clsDs.Add("", "@Type_Code", Some_Int_Value_Here, 4, Type_Code);