Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
Pass c# parameter to SqlQuery
Fares Ayyad
7y
324
1
Reply
string
SQLstr = @"
DISTINCT * FROM(
SELECT A.DOCNUMBR, A.CURNCYID, C.CRNCYSYM, C.CRNCYDSC, A.DOCDATE, B.CUSTNAME, A.TRXDSCRN, A.CHEKNMBR, CASE WHEN a.CURNCYID = (SELECT TOP 1 FUNLCURR FROM dbo.MC40000) THEN A.ORTRXAMT ELSE(SELECT ISNULL(SUM(ORDBTAMT), 0) FROM dbo.RM10101 WHERE DOCNUMBR = A.DOCNUMBR AND RMDTYPAL = 9) END AS CURTRXAM,
ISNULL((SELECT CMPNYNAM FROM DYNAMICS..SY01500 WHERE INTERID =
'TWO'
),
''
) AS COMPANYNAME
FROM dbo.RM10201 AS A
INNER JOIN RM00101 AS B ON A.CUSTNMBR = B.CUSTNMBR
INNER JOIN DYNAMICS..MC40200 AS C ON C.CURNCYID = A.CURNCYID
WHERE DOCNUMBR LIKE
'ParameterHere'
UNION ALL
SELECT A.DOCNUMBR,A.CURNCYID,C.CRNCYSYM,C.CRNCYDSC,A.DOCDATE,B.CUSTNAME,A.TRXDSCRN,A.CHEKNMBR,CASE WHEN a.CURNCYID = (SELECT TOP 1 FUNLCURR FROM dbo.MC40000 ) THEN A.ORTRXAMT ELSE (SELECT ISNULL(SUM(ORDBTAMT), 0) FROM dbo.RM10101 WHERE DOCNUMBR = A.DOCNUMBR AND RMDTYPAL = 9 ) END AS CURTRXAM ,
ISNULL((SELECT CMPNYNAM FROM DYNAMICS..SY01500 WHERE INTERID =
'TWO'
) ,
''
) AS COMPANYNAME
FROM dbo.RM20101 AS A
INNER JOIN RM00101 AS B ON A.CUSTNMBR = B.CUSTNMBR
INNER JOIN DYNAMICS..MC40200 AS C ON C.CURNCYID = A.CURNCYID
WHERE DOCNUMBR =
'ParameterHere'
) AS MAIN ";
SqlDataAdapter da =
new
SqlDataAdapter(SQLstr, obj.SQLConn);
DataSet ds =
new
DataSet();
da.SelectCommand.CommandTimeout = 99999999;
da.Fill(ds);
In the SQLstr how to pass parameter
CshRcptDocNum
to the query:
string
CshRcptDocNum = RmCashRept.RmCashReceipts.DocumentNumber.ToString().Trim();
I want to replace the ParameterHere in the query with
CshRcptDocNum string ?!
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
A billing and stock software for supermarket
Asy await Task.WhenAll is not working