我在 sql 编码方面很新,我无法在互联网上找到解决方案,这是我的代码:
CREATE PROCEDURE GET_SAMEDATE (@FileName VARCHAR(50))
AS
/* SET NOCOUNT ON */
SELECT Hash
FROM Beamer.PackageDetailFile A(NOLOCK)
INNER JOIN(SELECT FileName,
MAX(Date) MaxDate
FROM Beamer.PackageDetailFile(NOLOCK)
GROUP BY FileName)B
ON B.FileName = A.FileName
AND A.Date = B.MaxDate
WHERE FileName = @FileName
我想要做的是将文件名与我从 ac# 类获得的文件名进行比较
而且我也得到“不明确的列名'FileName'”
*模棱两可的列名已解决,但我仍然无法从其他类获取 FileName 来比较它们是否具有相同的文件名
c#代码
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand("dbo.GET_SAMEDATE", myConnection );
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
SqlDataReader sdr = myCommand.ExecuteReader();
while (sdr.Read())
{
string h = (string)sdr.GetString(0);
if (hash != h)
{
exists = true;
}
sdr.Read();
}