如何在mfc中运行sql命令 [英] How to run sql command in mfc

查看:76
本文介绍了如何在mfc中运行sql命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行查询

StateName的数据类型是ms中的文本访问2000

I want to run query
datatype of StateName is text in ms access 2000

CString cmd,statename;
m_CurrentStateCOMBO.GetWindowTextA(statename);
cmd.Format("select StateID from State where StateName=%s",statename);
m_recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,cmd,CRecordset::forwardOnly);





警告参数太少。预期1



如何跟随线路工作



warining is too few parameters. expected.1

how ever following line is working

datatype of StateID is number in ms access 2000
int sateid=3;
cmd.Format("select CityName from City where StateID=%d",sateid);
	m_recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,cmd,CRecordset::forwardOnly);

推荐答案

我认为您需要在州内引用名称如此处 [ ^ ]。
I think you need quotes around your state name as described here[^].


编辑以下行

Edit following line
cmd.Format("select StateID from State where StateName='"+statename+"'");


这篇关于如何在mfc中运行sql命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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