错误:最佳重载方法匹配' ClassData.Add(string,string,int,int,object)'有一些无效的论点

时间:2014-03-19 05:40:43

标签: c#

我在下面有以下错误我不知道我在这里缺少什么,或者我必须为它安装指令。错误是

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;
}

1 个答案:

答案 0 :(得分:0)

嗯,从错误消息中可以清楚地看出第3个参数类型是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);