How can I pass a vaule obtained from a user to a SQL query in MFC?

Hi,

I am using CRecordset::Open function to access data from a SQL Server 2005 database.

I am using it in the following way:

I have two CString type variables(c_username and c_password) which I am using to get input from the users.

CDatabase dbcon;
......
.......
CRecordset rs(&dbcon);
rs.Open(CRecordset::dynaset, _T("select * from INVENTORY..Inventory_Users where Inventory_user='c_username ' and Password='c_assword'"));

But it seems the values within c_username and c_password are not getting passed on to "Inventory_user" and "Password" to construct the query.

Can anyone help?
[676 byte] By [sudip_dg77] at [2007-11-20 1:00:10]
# 1 Re: How can I pass a vaule obtained from a user to a SQL query in MFC?
CString strSelect;

strSelect.Format("select * from INVENTORY..Inventory_Users where Inventory_user=\'%s\ ' and Password=\'%s\'', c_username, c_password);

rs.Open(CRecordset::dynaset, strSelect);
GCDEF at 2007-11-10 23:19:47 >
# 2 Re: How can I pass a vaule obtained from a user to a SQL query in MFC?
Thanks a billion!! It worked.
sudip_dg77 at 2007-11-10 23:20:53 >
# 3 Re: How can I pass a vaule obtained from a user to a SQL query in MFC?
Thanks a billion!! It worked.

Glad I could help. :)
GCDEF at 2007-11-10 23:21:52 >