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
sathish kumar
NA
117
165k
How to sum two values in sql server2008
Jul 23 2012 1:53 AM
Hi frnds,
I have to select a column value from a table and with that i have to sum another value using c#.net
i m selecting like this
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
DateTime ExDate = DateTime.ParseExact(txtExpiryDate.Text, "dd-MM-yyyy", CultureInfo.InvariantCulture);
string strSQL2 = "select [Opening_Qty] from [Stock] where [ItemName]='" + txtItemName.Text + "' AND [BatchNo]='" + txtBatchNo.Text + "' AND [ExpiryDate]='" + ExDate + "'";
SqlCommand cmdUpdate = new SqlCommand(strSQL2, sqlConn);
SqlDataReader drOpeningBalance = cmdUpdate.ExecuteReader();
if (drOpeningBalance.Read())
{
string OpeningQty = drOpeningBalance[0].ToString();
}
and
string strSQL1 = " Update [Stock] set [Opening_Qty]='" +( OpeningQty +(Convert.ToInt32(txtQty.Text)))+ "' where [ItemName]='" + txtItemName.Text + "' and [BatchNo]='" + txtBatchNo.Text + "'";
SqlCommand commandReader = new SqlCommand(strSQL1, sqlConn);
commandReader.ExecuteNonQuery();
like above lines i m summing up two values ...But its not working...Any suggestion pls...
Reply
Answers (
1
)
Open the image while click on the filename in datagridview
How to convert Guid to string and String to Guid..?