Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am implementing Project in vc++ 12 MFC. back-end is access database. I want to select all four columns values in one row into four variable.

My query is:
C++
m_txt = "select CompanyName As m_CompanyName, Model As m_Model, OrderNo As m_OrderNo, StreetAddress As m_StreetAddress , Phone As m_Phone, Logo As lg1 from Companies 


and I also want to get know how to specify where clause here as

C++
m_txt = "select CompanyName As m_CompanyName, Model As m_Model, OrderNo As m_OrderNo, StreetAddress As m_StreetAddress , Phone As m_Phone, Logo As lg1 from Companies where CompanyName="+s1;


That's how we write query in MySql or Sql server, s1 is variable of string type but in vc++ at + sign it gives error.

please help,it is very urjent
Posted
Updated 8-Jan-16 0:11am
v4
Comments
Kishor-KW 8-Jan-16 3:51am    
if I do concatenation then it will directly concatenate s1 with query, not the the value of s1.
Jochen Arndt 8-Jan-16 5:18am    
What type has the variable m_txt and if it is a char pointer how is memory allocated?
Kishor-KW 8-Jan-16 6:08am    
it is of CString type variable, Editbox member variable.
Kishor-KW 8-Jan-16 6:12am    
It is a MFC application

This is a duplicate of select query to select data into variable in vc++[^], which I already responded to. Please do not repost the same question, it just duplicates work for people.

And, no, it is not urgent.
 
Share this answer
 
As i mentioned in the comment to the question, all you need to do is to concatenate string!

Go back to C++ basics!

On the other hand, here is a tutorial about Developing Access 2007 Solutions with Native C or C++[^]
How To Invoke a Parameterized ADO Query Using VBA/C++/Java[^]

More resources:
Data Access in Visual C++[^]
Using the CDatabase class to read an Access databases[^]
Retrieving, Writing, and Creating Data in a Microsoft Access File (CDaoDatabase and CDaoRecordset)[^]


Next time, please use "Improve question" widget instead posting another one.
 
Share this answer
 
Comments
Kishor-KW 8-Jan-16 6:22am    
Thanks for reply but I already go through all links.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900