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. problem in inserting data

problem in inserting data

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasesysadmintutorial
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

    Hello friends,:doh: I am having difficuly in inserting data in database,I am able to do database connection with the help of oledb consumer wizard, For getting data from remote server i am using active -x events void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market,LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirection, LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) -------------------------------------------------------------------------------- And using dll function to Insert data short setQuoteToDB(BSTR* strDateTimeStamp, short* intMarketNo, BSTR* strMarketName, BSTR* strBid, BSTR* strAsk, short* intMarketState); But i am not successfull in data insertion can you help me how to do this... .do this need data casting...i am very new to progrraming...pls help me This is my code i am using: //this is acive x events for retriving data void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market, LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirect ion,LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) { // TODO: Add your control notification handler code here SessID=SessionId; CurrentRequestId=RequestId; txtMarket = Market; marketno.Format("%d",MarketNo); bid_d.Format("%c",BidDirection); ask_d.Format("%c",AskDirection); marketstate.Format("%d",MarketState); m_MainEdit=m_MainEdit + "" SessionId + RequestId + marketno ; m_MainEdit=m_MainEdit + Market + Bid + bid_d + Ask +ask_d + High ; m_MainEdit=m_MainEdit + Low + marketstate + Timestamp ; UpdateData(FALSE); iLineCount=m_EditCtrl.GetLineCount(); m_EditCtrl.LineScroll(iLineCount); //calling dll function _DBAccess db; db. setQuoteToDB(Timestamp,marketno,Market,B id,Ask,marketstate); UpdataData(TRUE); } -------------------------------------------------------------------------------- Errors::confused: 1)cannot convert parameter 1 from 'const char ** ' to 'unsigned short ** ' 2) cannot convert parameter 2 from 'class CString' to 'short *' 3) error C2664: 'setQuoteToDB' : cannot convert parameter 3 from 'const cha r *' to 'unsigned short ** ' 4) error C2664: 'setQuoteToDB' : cannot convert parameter 4 from 'const char *' to 'unsigned short ** ' 5)error C2664: 'setQuoteToDB' : cannot convert parameter 5 from 'const char

    P 1 Reply Last reply
    0
    • W With_problem

      Hello friends,:doh: I am having difficuly in inserting data in database,I am able to do database connection with the help of oledb consumer wizard, For getting data from remote server i am using active -x events void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market,LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirection, LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) -------------------------------------------------------------------------------- And using dll function to Insert data short setQuoteToDB(BSTR* strDateTimeStamp, short* intMarketNo, BSTR* strMarketName, BSTR* strBid, BSTR* strAsk, short* intMarketState); But i am not successfull in data insertion can you help me how to do this... .do this need data casting...i am very new to progrraming...pls help me This is my code i am using: //this is acive x events for retriving data void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market, LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirect ion,LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) { // TODO: Add your control notification handler code here SessID=SessionId; CurrentRequestId=RequestId; txtMarket = Market; marketno.Format("%d",MarketNo); bid_d.Format("%c",BidDirection); ask_d.Format("%c",AskDirection); marketstate.Format("%d",MarketState); m_MainEdit=m_MainEdit + "" SessionId + RequestId + marketno ; m_MainEdit=m_MainEdit + Market + Bid + bid_d + Ask +ask_d + High ; m_MainEdit=m_MainEdit + Low + marketstate + Timestamp ; UpdateData(FALSE); iLineCount=m_EditCtrl.GetLineCount(); m_EditCtrl.LineScroll(iLineCount); //calling dll function _DBAccess db; db. setQuoteToDB(Timestamp,marketno,Market,B id,Ask,marketstate); UpdataData(TRUE); } -------------------------------------------------------------------------------- Errors::confused: 1)cannot convert parameter 1 from 'const char ** ' to 'unsigned short ** ' 2) cannot convert parameter 2 from 'class CString' to 'short *' 3) error C2664: 'setQuoteToDB' : cannot convert parameter 3 from 'const cha r *' to 'unsigned short ** ' 4) error C2664: 'setQuoteToDB' : cannot convert parameter 4 from 'const char *' to 'unsigned short ** ' 5)error C2664: 'setQuoteToDB' : cannot convert parameter 5 from 'const char

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      abrakadbra wrote:

      db. setQuoteToDB(Timestamp,marketno,Market,B id,Ask,marketstate);

      You need to convert LPCTSTR to BSTR and pass its address as parameter. You can convert LPCTSTR to BSTR like this ;

      BSTR bsVar = SysAllocString(lpCstr);

      Do use SysFreeString() to release memory after use of BSTR.

      Prasad Notifier using ATL | Operator new[],delete[][^]

      W 1 Reply Last reply
      0
      • P prasad_som

        abrakadbra wrote:

        db. setQuoteToDB(Timestamp,marketno,Market,B id,Ask,marketstate);

        You need to convert LPCTSTR to BSTR and pass its address as parameter. You can convert LPCTSTR to BSTR like this ;

        BSTR bsVar = SysAllocString(lpCstr);

        Do use SysFreeString() to release memory after use of BSTR.

        Prasad Notifier using ATL | Operator new[],delete[][^]

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

        thanks...but can you pls tell me more detail as change in my code...sorry but i am very much confused

        P T 2 Replies Last reply
        0
        • W With_problem

          thanks...but can you pls tell me more detail as change in my code...sorry but i am very much confused

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          As told earlier, Its compilation error. You need to use BSTR pointer.Use SysAlloString to convert LPCTSTR. In case of CString object, you can use CString::AllocSysString for getting BSTR variable.

          Prasad Notifier using ATL | Operator new[],delete[][^]

          1 Reply Last reply
          0
          • W With_problem

            thanks...but can you pls tell me more detail as change in my code...sorry but i am very much confused

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            abrakadbra wrote:

            thanks...but can you pls tell me more detail as change in my code...sorry but i am very much confused

            Hai Mr. Jadugar,         you can use Much Better class _bstr_t which is wrapper over BSTR and provide mechanism for LPCTSTR too!

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

            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