久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

通過(guò)向當(dāng)前整數(shù)添加數(shù)字來(lái)更新 SQL 列

SQL Update Column By Adding A Number To Current Int(通過(guò)向當(dāng)前整數(shù)添加數(shù)字來(lái)更新 SQL 列)
本文介紹了通過(guò)向當(dāng)前整數(shù)添加數(shù)字來(lái)更新 SQL 列的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

很簡(jiǎn)單,我不知道如何將文本框中的整數(shù)添加(即 +)到 SQL 字段中的整數(shù).

Simple enough, I can't figure out how to add (that's +) an integer from a textbox to the integer in the SQL Field.

例如,SQL 字段中可能包含10",文本框中可能包含5".我想將這些數(shù)字加在一起以存儲(chǔ)15",而無(wú)需下載 SQL 表.

So for example, the SQL Field may have '10' in it and the textbox may have '5' in it. I want to add these numbers together to store '15' without having to download the SQL Table.

包含要添加到 SQL 整數(shù)的整數(shù)的文本框是 tranamount.Text,SQL 表中的 SQL 列是 @ugpoints.請(qǐng)注意,如果沒有+"——這在下面的代碼中是公認(rèn)的錯(cuò)誤——tranamount.Text 的值被添加到表中沒有問(wèn)題,但它只是替換了原始值;這意味著最終結(jié)果在 SQL 字段中將是5".

The textbox that contains the integer to be added to the SQL integer is tranamount.Text and the SQL Column in the SQL Table is @ugpoints. Please note, without the '+' - which is in the below code and is admittedly wrong- the value of tranamount.Text is added to the Table without an issue, but it simply replaces the original value; meaning the end result would be '5' in the SQL Field.

構(gòu)建它的正確方法是什么?我已經(jīng)嘗試了下面的代碼,但這顯然不起作用.

What would be the proper way to structure this? I've tried the below code, but that clearly doesn't work.

cmd = New SqlCommand("UPDATE PersonsA SET U_G_Studio=@ugpoints WHERE Members_ID=@recevierID", con)

cmd.Parameters.AddWithValue("@recevierID", tranmemberID.Text)
cmd.Parameters.AddWithValue("@ugpoints", + tranamount.Text) '<--- Value to add.
cmd.ExecuteNonQuery()

新手問(wèn)題我知道,我是 vb 中的 SQL 新手.

Newbies question I know, I'm new to SQL in vb.

推薦答案

U_G_Studio字段的當(dāng)前值,加上參數(shù)的值,重新賦值給U_G_Studio,但請(qǐng)記住,您需要將值作為整數(shù)傳遞,否則 AddWithValue 將傳遞一個(gè)字符串,并且您會(huì)收到來(lái)自數(shù)據(jù)庫(kù)的轉(zhuǎn)換錯(cuò)誤.

Take the current value of the U_G_Studio field, add the value of the parameter and reassign to U_G_Studio, but keep in mind that you need to pass the value as an integer because otherwise the AddWithValue will pass a string and you get conversion errors coming from the db.

    cmd = New SqlCommand("UPDATE PersonsA SET U_G_Studio=U_G_Studio + @ugpoints " & 
                         "WHERE Members_ID=@recevierID", con)
    cmd.Parameters.AddWithValue("@recevierID", tranmemberID.Text)
    cmd.Parameters.AddWithValue("@ugpoints", Convert.ToInt32(tranamount.Text))
    cmd.ExecuteNonQuery()

這篇關(guān)于通過(guò)向當(dāng)前整數(shù)添加數(shù)字來(lái)更新 SQL 列的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應(yīng)該使用什么 SQL Server 數(shù)據(jù)類型來(lái)存儲(chǔ)字節(jié) [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數(shù)據(jù))
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
How to convert #39;2016-07-01 01:12:22 PM#39; to #39;2016-07-01 13:12:22#39; hour format?(如何將“2016-07-01 01:12:22 PM轉(zhuǎn)換為“2016-07-01 13:12:22小時(shí)格式?)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應(yīng)該返回“1?什么時(shí)候不能投射為日期?)
主站蜘蛛池模板: 久久精品国产一区二区电影 | 国产 欧美 日韩 一区 | 午夜精品福利视频 | 欧美久久综合 | 婷婷狠狠 | 九九精品在线 | 午夜影院网站 | www成人免费 | 尤物在线 | 色天堂视频 | 中文在线一区二区 | 91精品久久久久久久久久入口 | 国产成人精品一区二区三区 | 在线中文字幕日韩 | 91免费在线播放 | 日韩视频一区二区在线 | 精品视频免费 | 一区二区三区回区在观看免费视频 | 免费一级黄色录像 | 欧美三级免费观看 | 玖草资源 | 国产欧美精品一区二区 | 99精品久久久久久 | 97超碰站 | 亚洲一区精品视频 | 成人欧美一区二区三区1314 | 久久久久国产一区二区三区 | 国产成人av一区二区三区 | 久久99精品久久久久久琪琪 | 亚洲综合国产精品 | 国产免费观看久久黄av片涩av | jizz亚洲人 | 久久久久久久一区 | 久久中文免费视频 | 国产高清在线精品一区二区三区 | 久久久精品久 | 国产精品久久久久aaaa九色 | 男人天堂社区 | 国产欧美一区二区三区日本久久久 | 久久日韩精品一区二区三区 | 国产精品久久网 |