vc ++ MFC中select查询的where子句的语法 [英] syntax for where clause of select query in vc++ MFC

查看:231
本文介绍了vc ++ MFC中select查询的where子句的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vc ++ 12 MFC中实现Project。后端是访问数据库。我想将一行中的所有四列值选择为四个变量。



我的查询是:

 m_txt =  选择CompanyName为m_CompanyName,Model为m_Model,OrderNo为m_OrderNo,StreetAddress为m_StreetAddress,Phone为m_Phone,Logo来自公司的lg1  





我也想知道如何在这里指定where子句



 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其中CompanyName = + s1; 





这就是我们在MySql或Sql server中编写查询的方式,s1是字符串类型的变量,但在vc ++ at + sign中它给出了错误。



please帮助,非常urjent

解决方案

这是的副本选择查询以在vc ++中选择数据到变量 [ ^ ],我已经回复了。请不要重新发布同样的问题,它只是为人们重复工作。



而且,不,这不紧急。


正如我在问题的评论中提到的,你需要做的就是连接字符串!



回到C ++基础知识!



另一方面,这是一个关于使用Native C或C ++开发Access 2007解决方案 [ ^ ]

如何使用VBA / C ++ / Java调用参数化ADO查询 [ ^ ]



更多资源:

Visual C ++中的数据访问 [ ^ ]

< a href =http://www.codeproject.com/KB/database/readdb.aspx>使用CDatabase类读取Access数据库 [ ^ ]

检索,编写和创建Microsoft Access文件(CDaoDatabase和CDaoRecordset)中的数据 [ ^ ]





下次,请使用改善问题小部件,而不是发布另一个小部件。

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:

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

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

解决方案

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.


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.


这篇关于vc ++ MFC中select查询的where子句的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆