国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
C#中SQLserver語(yǔ)句insert語(yǔ)句無法更新數(shù)據(jù)

很抱歉啊大家,之前上傳的代碼不是很詳細(xì),現(xiàn)在我把這一段的代碼全部放上來
private void OrderFoodAddButton_Click(object sender, EventArgs e)
{
if (IndentOderID != null)
{
using (SqlConnection conn = new SqlConnection(connectiongString))
{
conn.Open();
//↓
string sqlstring, FoodName;
int FoodId = Convert.ToInt32(comboBox1.SelectedValue);
decimal FoodPrice;
Int64 OrderId = Convert.ToInt64(IndentOderID.Text.ToString());
sqlstring = "select FoodName,FoodPrice from FoodTab where FoodId=" + FoodId + "";//根據(jù)選擇的食物搜索出食物名字,食物價(jià)格
SqlCommand cmd = new SqlCommand(sqlstring, conn);
SqlDataReader readfood = cmd.ExecuteReader();
//
readfood.Read();
FoodName = readfood[0].ToString();
FoodPrice = Convert.ToDecimal(readfood[1].ToString());
readfood.Close();
//

                sqlstring="select OrderPrice from OrderTab where OrderId='"+OrderId+"'";//找出這個(gè)訂單的價(jià)格                SqlCommand cmd1 = new SqlCommand(sqlstring, conn);                SqlDataReader readPrice = cmd1.ExecuteReader();                //                readPrice.Read();                decimal OrderPrice=Convert.ToDecimal(readPrice[0].ToString());                readPrice.Close();                //                OrderPrice = OrderPrice + FoodPrice;//將訂單價(jià)格更新                sqlstring = "select max(RelationId) as RelationIdMax from RelationTab";//找出關(guān)系表中關(guān)系ID最大項(xiàng)                SqlCommand cmd2 = new SqlCommand(sqlstring, conn);                SqlDataReader readrelationIdMax = cmd2.ExecuteReader();                //                readrelationIdMax.Read();                int RelationIdMax = Convert.ToInt32(readrelationIdMax[0].ToString());                RelationIdMax = ++RelationIdMax;//自加確保關(guān)系ID唯一                readrelationIdMax.Close();                //;                string sqlUpdataString = "insert into table_RelationTab(RelationId,FoodId,OrderId,FoodName,FoodPrice) values(" + RelationIdMax + "," + FoodId + "," + OrderId + ",'" + FoodName + "'," + FoodPrice + ")";//更新關(guān)系表                SqlCommand cmd3 = new SqlCommand(sqlUpdataString, conn);                cmd3.CommandText = sqlUpdataString;                sqlUpdataString = "update OrderTab set OrderPrice="+OrderPrice+" where OrderId="+OrderId+"";//更新訂單總價(jià)                SqlCommand cmd4 = new SqlCommand(sqlUpdataString, conn);                cmd4.CommandText = sqlUpdataString;                sqlstring = "select RelationId,FoodName,FoodPrice from RelationTab where OrderId=" + OrderId + "";//找出關(guān)系表中更新后的菜譜,用于刷新GridView控件                SqlCommand cmd5 = new SqlCommand(sqlstring, conn);                cmd5.CommandText = sqlstring;                SqlDataAdapter adpfood = new SqlDataAdapter(sqlstring, conn);                DataSet dsfood = new DataSet();                adpfood.Fill(dsfood);                IndentBindingSource.DataSource = dsfood.Tables[0].DefaultView;                IndentGridView.DataSource = IndentBindingSource;                //                IndentOrderPrice.Text = OrderPrice.ToString();//更新價(jià)格顯示                //↑                conn.Close();            }        }
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
操作數(shù)據(jù)庫(kù)類SQLHelp.cs
mysql數(shù)據(jù)庫(kù)經(jīng)驗(yàn)總結(jié)(原創(chuàng))
使用C#創(chuàng)建SQL Server的存儲(chǔ)過程(Visual Studio 2005 SQL Server 2005)
C#讀取.sql文件并執(zhí)行文件中的sql
C#MysqlHelper
實(shí)現(xiàn)SqlParameter方式
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服