Hi Friends,
i am using QODBC for connecting "SQL Server"...
i want to pass the int variable in WHERE clause in QSqlQuery ...
below is the code snippet:
QSqlQuery query;
query.exec("SELECT AOA,CL,CD,CM FROM Test_Validity WHERE (Campaign_Nr=232 AND Serie_Nr=8)");
in the above query i want to pass the int variable in WHERE clause instead of the constant...
i had searched in google related to this problem... and found some stuffs which are related to the current problem..
solution#1:http://www.mssqltips.com/tip.asp?tip=1160
1. Writing a query with parameters(Dynamic SQL statement in SQL Server..)
[if you only need to pass parameters into your WHERE clause of your SQL statement. Let's say we need to find all records from the customers table where City = 'London'. This can be done easily such as the following example shows.
DECLARE @city varchar(75)
SET @city = 'London'
SELECT * FROM customers WHERE City = @city]
as per the above example....if i write
DECLARE @cno int
SET @cno = currentcno
then it gives problem...
solution#2:
creating the STORED PROCEDURE
i dont know how to create the "STORED PROCEDURE" and use it in QT
please help me to solve this problem..
Thanks in Advance,
Muthu
Bookmarks