저장 프로 시저를 실행하고 해당 저장 프로 시저의 값을 반환하는 메서드가 있습니다. SQL에서 VarBinary
유형의 VIN이 있습니다. 나는 값을 얻기 위해 무엇을 사용할 수 있는지 잘 모르겠습니다. 이 반환 가정되는 값은 그러나 44을 반환C#의 GetBytes가 올바른 값을 반환하지 않습니다.
VIN =result.GetBytes(3,0,outByte,0,bufferSize)
:
0x00D1CCE9771AE7554D479F7B93A45611010000004158D130E5097EF2924DEC4C6255E5BAF4C8EF4C2AC2A8FD9F29295F41DA3550123C6C4575788F5E6
// Get Customer Product By CustomerID
public Model.CustomerProduct Get_CustomerProduct(int Customer_ID)
{
Model.CustomerProduct model = null;
string myConnection = System.Configuration.ConfigurationManager.ConnectionStrings[connectionName].ToString();
SqlDatabase db = new SqlDatabase(myConnection);
int bufferSize = 100;
byte[] outByte = new byte[bufferSize];
using (DbCommand command = db.GetStoredProcCommand("Get_Customer_Product"))
{
db.AddInParameter(command, "Customer_ID", DbType.Int32, Customer_ID);
var result = db.ExecuteReader(command);
try
{
if (result.FieldCount == 0)
model = null;
else
{
result.Read();
model = new Model.CustomerProduct()
{
Product_Name = result.GetString(2)
,VIN =result.GetBytes(3,0,outByte,0,bufferSize) // this return me wrong
};
}
}
catch (Exception ex)
{
}
return model;
}
}
내 문제는이 라인 :
이
내 코드입니다
감사합니다.하지만 모든 내용은 00000000000000000000000000000000000000000000000000000000입니다. – Alma
db의 필드 유형은 무엇입니까? – Chris
db 형식이 VarBinary (500) – Alma