Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. ADO SQL SERVER - invalid char value for cast specification error

ADO SQL SERVER - invalid char value for cast specification error

Scheduled Pinned Locked Moved Database
databasehelpsql-servercomsysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haritadala
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups