[WebMethod]
public string GetPatientMasterIndex(string PatientId, string InpNO)
{
using (SqlConnection con = new SqlConnection("略"))//你的链接
{
con.Open();
DataTable dt = new DataTable();
if (PatientId != "")//第一个唯一标识
{
SqlDataAdapter da = new SqlDataAdapter("SELECT (SELECT PatientId,InpNO,Name,NamePhonetic,Sex,DateOfBirth,BirthPlace,Citizenship,Nation,IDNO FROM [table] WHERE PatientId=tb.PatientId FOR XML PATH('')) AS tbList FROM [table] tb where PatientId='" + PatientId + "'", con);//生成XML的SQL语句
da.Fill(dt);
return dt.Rows.Count == 0 ? "" : dt.Rows[0][0].ToString();//返回字符串,无此ID返回空字符
}
else if (InpNO != "")//第二个唯一标识
{
SqlDataAdapter da = new SqlDataAdapter("SELECT (SELECT PatientId,InpNO,Name,NamePhonetic,Sex,DateOfBirth,BirthPlace,Citizenship,Nation,IDNO FROM [table] WHERE InpNO=tb.InpNO FOR XML PATH('')) AS tbList FROM [table] tb where InpNO='" + InpNO + "'", con);
da.Fill(dt);
return dt.Rows.Count == 0 ? "" : dt.Rows[0][0].ToString();
}
else
{
return "";//两ID均无,返回空字符
}
}
}
邮箱:460302176@qq.com