TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Fares Ayyad
NA
235
74.6k
Pass c# parameter to SqlQuery
Jun 14 2017 9:01 AM
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 ?!
Reply
Answers (
2
)
A billing and stock software for supermarket
Asy await Task.WhenAll is not working