ADO SQL SERVER - invalid char value for cast specification error
-
Hello all I'm connecting to sqlserver using ADO and trying to execute a stored procedure. I'm getting an error like "invalid char value for cast specification error". I've the following code to execute the stored procedure. setproc(int devid,char *cfgid,char *lmsgid) { try{ m_Command.CreateInstance(__uuidof(Command)); //using already created connection object m_Command->ActiveConnection = m_Connection; m_Command->CommandType = adCmdStoredProc; m_Command->CommandText = "usp_IsIDExist"; _ParameterPtr pParam1, pParam2,pParam3; pParam1=m_Command->CreateParameter(bstr_t ("DevID"), adTinyInt,adParamInput,sizeof (BYTE),_variant_t (long(devid))); m_Command->Parameters->Append(pParam1); pParam2=m_Command->CreateParameter(bstr_t ("CfgID"), adVarChar,adParamInput,1,(_bstr_t)cfgid); m_Command->Parameters->Append(pParam2); pParam3=m_Command->CreateParameter(bstr_t ("LastMsgID"), adVarChar,adParamInput,strlen(lmsgid),(_bstr_t)lmsgid); m_Command->Parameters->Append(pParam3); m_Recordset = m_Command->Execute( &vNull, &vNull, adCmdStoredProc); }catch(com_error &e){} } I've the following strored procedure ..... CREATE PROCEDURE usp_IsIDExist @DevID integer, @CfgID char(1), @MsgID varchar(255) AS BEGIN IF (SELECT COUNT(*) FROM dbo.MsgLog WHERE DevID = @DevID AND CfgID = @CfgID AND MsgID = @MsgID) <> 0 SELECT Result = 1 ELSE SELECT Result = 0 END in msglog table devid -- int,cfgid -- char(1) and msgid -- varchar(255). Is there anything wrong this code. I tried it on two machines, on one machine it worked where on another machine if failed giving me the above mentioned error. Both machines have the same database setup except the fact that one is win2000 server and another one is win2000 prof. Can anyone help me in this? Many thanks for your help. Hari.