0

如何通过存储过程将一个字节数组从 ac# windows 应用程序传递到 SQL Server?我在 SQL 中的代码:

        INSERT INTO Pers_UserMachine (userID,nbOfTemplates,fingerPrint1,fingerPrint2,fingerChecksum1,fingerChecksum2)
         VALUES(
            @UserID,            
            @NbOfTemplates,
            CONVERT(VARBINARY(MAX),@FingerPrint1),
            CONVERT(VARBINARY(MAX),@FingerPrint2),
            @fingerChecksum1,
            @fingerChecksum2
                )

和我在 c# 中的代码:

    public int SaveUser(int ID, string UserID, int NbOfTemplates, byte [] FingerPrint1, byte [] FingerPrint2, Int32 fingerChecksum1, Int32 fingerChecksum2)
    {
        try
        {
            HybridDictionary paramsDictionary = new HybridDictionary();

            paramsDictionary.Add("@ID", ID);
            paramsDictionary.Add("@UserID", UserID);
            paramsDictionary.Add("@NbOfTemplates", NbOfTemplates);
            paramsDictionary.Add("@FingerPrint1", FingerPrint1);
            paramsDictionary.Add("@FingerPrint2", FingerPrint2);
            paramsDictionary.Add("@fingerChecksum1", fingerChecksum1);
            paramsDictionary.Add("@fingerChecksum2", fingerChecksum2);

            DABase da = new DABase();
            return int.Parse(da.GetScalar("PunchMachineSaveUser", paramsDictionary).ToString());
        }
        catch (Exception ex)
        {
            return -1;
        }
    }
4

0 回答 0