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

通過向當前整數添加數字來更新 SQL 列

SQL Update Column By Adding A Number To Current Int(通過向當前整數添加數字來更新 SQL 列)
本文介紹了通過向當前整數添加數字來更新 SQL 列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

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

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".我想將這些數字加在一起以存儲15",而無需下載 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 整數的整數的文本框是 tranamount.Text,SQL 表中的 SQL 列是 @ugpoints.請注意,如果沒有+"——這在下面的代碼中是公認的錯誤——tranamount.Text 的值被添加到表中沒有問題,但它只是替換了原始值;這意味著最終結果在 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.

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

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()

新手問題我知道,我是 vb 中的 SQL 新手.

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

推薦答案

U_G_Studio字段的當前值,加上參數的值,重新賦值給U_G_Studio,但請記住,您需要將值作為整數傳遞,否則 AddWithValue 將傳遞一個字符串,并且您會收到來自數據庫的轉換錯誤.

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()

這篇關于通過向當前整數添加數字來更新 SQL 列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應該使用什么 SQL Server 數據類型來存儲字節 [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數據)
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轉換為“2016-07-01 13:12:22小時格式?)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應該返回“1?什么時候不能投射為日期?)
主站蜘蛛池模板: 国产视频久久久久 | 欧美日韩精品一区 | 99精品免费 | 一区二区三区四区国产 | 成人不卡 | 欧美亚洲一区二区三区 | 成人免费久久 | 成人在线视频一区 | 精品婷婷 | 久久久久久久一区 | 91精品久久久 | 国产欧美一区二区三区免费 | 亚洲精品视频在线观看免费 | 波多野结衣电影一区 | 国产清纯白嫩初高生在线播放视频 | 成人午夜毛片 | 天天干.com | 91欧美 | 无码日韩精品一区二区免费 | 日本免费视频在线观看 | 亚洲视频一区在线观看 | 中文字幕日韩av | 久久久久久久久久久久久久久久久久久久 | 国产精品一区久久久 | 福利片在线 | 亚洲一区二区三区高清 | 日韩伦理一区二区三区 | a级大片 | 99国产精品99久久久久久 | 国产激情在线 | 亚洲综合成人网 | 国产精品国产三级国产aⅴ浪潮 | 在线播放亚洲 | 最新中文字幕 | 麻豆精品国产91久久久久久 | 久久大| 在线观看h视频 | 中文字字幕一区二区三区四区五区 | 国产精品99免费视频 | 亚洲精品观看 | 久久久久久久97 |