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
Shaik Ali
NA
46
983
Update Table Based on Select Statment
Jun 30 2019 11:33 AM
Dear Experts
i am using two queries to update a talbe it work fine.
but i would like to convert this into one query. please Guide me
try
{
OleDbCommand cmd1 = new OleDbCommand(@"SELECT BID, SUM( IIF( TTYPE IN ('P','R','T','I') ,(Qty+QtyFree) ,0 )) AS TOT_IN,
SUM( IIF(TTYPE IN ('S','B','N','O') ,(Qty+QtyFree) , 0)) AS TOT_OUT,
SUM( IIF(TTYPE IN ('A') ,(Qty+QtyFree) , 0)) AS TOT_ADJ, TOT_IN - TOT_OUT + TOT_ADJ AS TOT_STK From Detail where BID = '" + bid + "' GROUP BY BID", cn); //and [HEADER] <> '" + dgvRestQty.Rows[i].Cells["HEADER"].Value + "'
dr = cmd1.ExecuteReader();
if (dr.Read())
{
OleDbCommand cmd11 = new OleDbCommand("update BATCH set QinHand = " + dr["TOT_STK"].ToString() + " where BID = '" + bid + "' ", cn);
cmd11.ExecuteNonQuery();
}
}
catch { }
thanks you
Reply
Answers (
2
)
Xamarin Forms Shell
I am developing project help me on ado net