in this post you can learn about the sum query to SQL server column amount using vb.net. it means when you want to sum your total amount text box data to SQL server column then you should use the below coding as per video instruction. it is very important query for our software because when the costumer paid their loan or take a load from sellers then you have to use this query we can use it for two purpose such as minus and sum. if we want to sum in SQL server total amount column or if we want to minus. we always need this query for our database.
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.IO
Public Class Form1
Dim ccnn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=G:\WindowsApplication4\WindowsApplication4\Database2.mdf;Integrated Security=True;User Instance=True")
Dim cmded As New SqlCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmded As New SqlCommand
cmded.Connection = ccnn
cmded.Parameters.Add("@ID", SqlDbType.Int).Value = "1"
cmded.CommandText = ("UPDATE Table1 SET ID = @ID,Amount =CAST((CAST(Amount AS INT)+" + TextBox3.Text + ") AS VARCHAR(10)) WHERE ID = @ID")
ccnn.Open()
cmded.ExecuteNonQuery()
ccnn.Close()
TextBox3.Text = ""
MessageBox.Show("Sucessfuly Done")
End Sub
End Class