izakref
asked on
VC ADO CreateParameter
Hi
Is there any way to work under VC++ with CreateParameter without give the parameters hardcoded (to dinamicly sent parameter to StoreProcedure).
Izak
Is there any way to work under VC++ with CreateParameter without give the parameters hardcoded (to dinamicly sent parameter to StoreProcedure).
Izak
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
listening ..
You have 2 options when working with ADO, and it doesn't matter if it is from VC++ or VB or something else.
1) you issue first a command->Parameters->Refre sh() call and from there on you just set the values of the parameters, because the parameters collection is already created
2) you know exactly the order and number of the required srtored procedure parameters ( there can be optional parameters to an SP, and they don't have to be specified in ADO command ), and you issue command->CreateParameter() calls for each parameter and in the correct order
Hope this clears teh things a little,
Cri
1) you issue first a command->Parameters->Refre
2) you know exactly the order and number of the required srtored procedure parameters ( there can be optional parameters to an SP, and they don't have to be specified in ADO command ), and you issue command->CreateParameter()
Hope this clears teh things a little,
Cri
izakref will You happy with:
szSQL=(LPTSTR)malloc(255);
wsprintf((LPTSTR)szSQL,"ex ec sp_CreateUser @username='%s', @userpassword='%s', @withupdate=1",m_strUserNa me,m_strPa ssword);
using connection:
pConnection.CreateInstance (__uuidof( Connection ));
pConnection->Open((_bstr_t ) "DRIVER={SQL Server};UID=blabla;PWD=123 4;SERVER=S UPER;DATAB ASE=LARGE" ,"","",NUL L);
pConnection->Execute((_bst r_t) szSQL,NULL,adCmdText);
pConnection->Close();
using recordset, when You need output results:
pRecSet.CreateInstance(__u uidof(Reco rdset));
//select data from SQL server
pRecSet->Open( (const _variant_t &) szSQL
, (const _variant_t &) "DRIVER={SQL Server};UID=blabla;PWD=123 4;SERVER=S UPER;DATAB ASE=LARGE" , adOpenForwardOnly
, adLockBatchOptimistic
, adCmdText);
just dynamically creae szSQL, and go!
good luck!
szSQL=(LPTSTR)malloc(255);
wsprintf((LPTSTR)szSQL,"ex
using connection:
pConnection.CreateInstance
pConnection->Open((_bstr_t
pConnection->Execute((_bst
pConnection->Close();
using recordset, when You need output results:
pRecSet.CreateInstance(__u
//select data from SQL server
pRecSet->Open( (const _variant_t &) szSQL
, (const _variant_t &) "DRIVER={SQL Server};UID=blabla;PWD=123
, adLockBatchOptimistic
, adCmdText);
just dynamically creae szSQL, and go!
good luck!
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity, I will suggest to accept "missionImpossible" comment(s) as an answer.
If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner