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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error:c2664:cannot convert parameter 1 from 'const char *' to 'unsigned short ** '

error:c2664:cannot convert parameter 1 from 'const char *' to 'unsigned short ** '

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasetutorial
5 Posts 3 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.
  • W Offline
    W Offline
    With_problem
    wrote on last edited by
    #1

    i am using this dll function to insert data in database but it give me following error...how to slove this can anybody there help me setQuoteToDB(Timestamp,a,Market,Bid,Ask,d); Error:cannot convert parameter 1 from 'const char *' to 'unsigned short ** '

    C R 2 Replies Last reply
    0
    • W With_problem

      i am using this dll function to insert data in database but it give me following error...how to slove this can anybody there help me setQuoteToDB(Timestamp,a,Market,Bid,Ask,d); Error:cannot convert parameter 1 from 'const char *' to 'unsigned short ** '

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      It would be nice to explain your problem a litle bit better (and also to post some code to show how you are using the function). To me the error is clear: you pass a pointer to a char array and the function needs an unsigned short** instead.


      Cédric Moonen Software developer
      Charting control [v1.1]

      W 1 Reply Last reply
      0
      • C Cedric Moonen

        It would be nice to explain your problem a litle bit better (and also to post some code to show how you are using the function). To me the error is clear: you pass a pointer to a char array and the function needs an unsigned short** instead.


        Cédric Moonen Software developer
        Charting control [v1.1]

        W Offline
        W Offline
        With_problem
        wrote on last edited by
        #3

        this is my code....can you just tell me how to convert it....this is dll function... m_MainEdit=m_MainEdit + "" +" " + SessionId + "\t" + RequestId +"\t"+ a ; m_MainEdit=m_MainEdit + "\t"+ Market + "\t " + Bid + "\t " + b + " \t"+ Ask + "\t" +c +"\t "+ High + "\t"; m_MainEdit=m_MainEdit + Low + "\t" + d + " "+ "\t" + Timestamp + "\r\n"; UpdateData(FALSE); iLineCount=m_EditCtrl.GetLineCount(); m_EditCtrl.LineScroll(iLineCount); _DBAccess db; db.setQuoteToDB(Timestamp,a,Market,Bid,Ask,d);

        C 1 Reply Last reply
        0
        • W With_problem

          this is my code....can you just tell me how to convert it....this is dll function... m_MainEdit=m_MainEdit + "" +" " + SessionId + "\t" + RequestId +"\t"+ a ; m_MainEdit=m_MainEdit + "\t"+ Market + "\t " + Bid + "\t " + b + " \t"+ Ask + "\t" +c +"\t "+ High + "\t"; m_MainEdit=m_MainEdit + Low + "\t" + d + " "+ "\t" + Timestamp + "\r\n"; UpdateData(FALSE); iLineCount=m_EditCtrl.GetLineCount(); m_EditCtrl.LineScroll(iLineCount); _DBAccess db; db.setQuoteToDB(Timestamp,a,Market,Bid,Ask,d);

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          Geez, you are not very helpfull !! What is the prototype of setQuoteToDB ? And what are the actual parameters that you pass to the function ? What is Timestamp, what is a, what is Market, what is Bid, what is Ask and what is d ? Don't you understand that you are passing a wrong type of parameter to the function ? So how can I help you if you actually don't provide me with the information about what the function is expecting and what you actually pass to the function.


          Cédric Moonen Software developer
          Charting control [v1.1]

          1 Reply Last reply
          0
          • W With_problem

            i am using this dll function to insert data in database but it give me following error...how to slove this can anybody there help me setQuoteToDB(Timestamp,a,Market,Bid,Ask,d); Error:cannot convert parameter 1 from 'const char *' to 'unsigned short ** '

            R Offline
            R Offline
            Roger Stoltz
            wrote on last edited by
            #5

            Half of this reply is just guesses from my side since you don't provide much information. There seem to be two problems here: 1. the dll func expects a parameter which is a pointer to a pointer to an 'unsigned short', but you provide it with a pointer to a 'const char'. I suspect the dll func to expect a BSTR* and it's an out-parameter, i.e. you'll get a B-string as a result of the dll func. If this is the case it could look like this:

            BSTR bstrTheString = NULL;
            setQuoteToDB( ..., &bstrTheString, ...);

            Otherwise if it really is an unsigned short:

            unsigned short* pMyValue = NULL; // Or where ever it should point
            setQuoteToDB( ..., &pMyValue, ...);

            2. You're trying to convert a 'const' value to a 'non-const' which in all cases gives a compiler error. By declaring something 'const' you sign a contract where you promise not to change the value. The compiler complains if you're trying to violate that contract by type-casting to a 'non-const' type. Hope this helps -- Roger


            "It's supposed to be hard, otherwise anybody could do it!" - selfquote

            "No one remembers a coward!" - Jan Elfström 1998
            "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above

            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