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")
Nesta página do site você pode assistir ao vídeo on-line VB.NET and SQL Server - How to Update data in SQL Server Database using Vb.net. duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário VB Programming Lab 05 Junho 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 34 vezes e gostou 0 espectadores. Boa visualização!