VB.NET and SQL Server - How to Update data in SQL Server Database using Vb.net
#sqlserver #vb.net #update
Code:-
Public sqlconn As New SqlConnection
Dim connstring = ""
sqlconn.ConnectionString = connstring
Dim dtStudent As New DataTable
Dim cmdStudent As New SqlCommand("USP_Select_StudentData", sqlconn)
cmdStudent.Parameters.Add("@StudentID", SqlDbType.Int).Value = txtSearchStuID.Text
cmdStudent.CommandType = CommandType.StoredProcedure
Dim daStudent As New SqlDataAdapter
daStudent.SelectCommand = cmdStudent
daStudent.Fill(dtStudent)
txtStudentID.Text = dtStudent.Rows(0).Item(0).ToString
txtStudentName.Text = dtStudent.Rows(0).Item(1).ToString
txtUniversity.Text = dtStudent.Rows(0).Item(2).ToString
txtCourse.Text = dtStudent.Rows(0).Item(3).ToString
txtGender.Text = dtStudent.Rows(0).Item(4).ToString
txtAge.Text = dtStudent.Rows(0).Item(5).ToString
Dim cmdUpdateStdData As New SqlCommand("USP_Update_StudentData", sqlconn)
cmdUpdateStdData.CommandType = CommandType.StoredProcedure
cmdUpdateStdData.Parameters.Add("@StudentID", SqlDbType.Int).Value = txtSearchStuID.Text
cmdUpdateStdData.Parameters.Add("@StudentName", SqlDbType.VarChar).Value = txtStudentName.Text
cmdUpdateStdData.Parameters.Add("@University", SqlDbType.VarChar).Value = txtUniversity.Text
cmdUpdateStdData.Parameters.Add("@Course", SqlDbType.VarChar).Value = txtCourse.Text
cmdUpdateStdData.Parameters.Add("@Gender", SqlDbType.VarChar).Value = txtGender.Text
cmdUpdateStdData.Parameters.Add("@Age", SqlDbType.Int).Value = txtAge.Text
sqlconn.Open()
cmdUpdateStdData.ExecuteNonQuery()
sqlconn.Close()
MsgBox("Record Updated", MsgBoxStyle.OkOnly, "Student form")
On this page of the site you can watch the video online VB.NET and SQL Server - How to Update data in SQL Server Database using Vb.net. with a duration of hours minute second in good quality, which was uploaded by the user VB Programming Lab 05 June 2020, share the link with friends and acquaintances, this video has already been watched 34 times on youtube and it was liked by 0 viewers. Enjoy your viewing!