I have a logTable in my database for log changes on someTable.
logTable has three columns:
first for store column name which value was changed;
second for old value;
third for new value.
Second and third column has sql_variant data type.
In my program I get data from this table and oldValue and newValue are an arrays of bytes.
For example:
rows in logTable:
columnName(nvarchar(50)) oldValue(sql_variant) newValue(sql_variant)
compName name1 name2
address "address1" "address2"
zip 123 134
phone 123456789 987654321
But I get oldValue and newValue values in byte arrays.
Like:
address "byte array" "byte array"
zip "byte array" "byte array"
phone "byte array" "byte array"
instead:
address "address1" "address2"
zip 123 134
phone 123456789 987654321
This code I use to get data from DB:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open connStr
Set rsData = Server.CreateObject("ADODB.Recordset")
Set objComm = Server.CreateObject("ADODB.Command")
Set objComm.ActiveConnection= Conn
objComm.CommandText="usp_Log_GetOperationDetails"
objComm.CommandType = adCmdStoredProc
objComm.Parameters.Append objComm.CreateParameter("@CompanyId",adInteger,adParamInput)
objComm.Parameters("@CompanyId")=Request("CompanyId")
objComm.Parameters.Append objComm.CreateParameter("@tableName",adVarChar,adParamInput, 50)
objComm.Parameters("@tableName")=Request("tableName")
rsData.CursorLocation = adUseClient
rsData.CursorType = adOpenStatic
Set rsData.Source = objComm
rsData.Open
If NOT rsData.EOF AND NOT rsData.BOF then
Do While NOT rsData.EOF
rsDataOldValue = rsData("OldValue")
rsDatanewValue = rsData("NewValue")
rsData.MoveNext
Loop
End If
rsData.Close
Set rsData = Nothing
Conn.Close
Set Conn = Nothing
Set objComm = Nothing
How can I convert byte array to correct string value?
Thanks
newValueandoldValue? I don't really understand what you expect to get and what you're actually getting