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")
In questa pagina del sito puoi guardare il video online VB.NET and SQL Server - How to Update data in SQL Server Database using Vb.net. della durata di ore minuti seconda in buona qualità , che l'utente ha caricato VB Programming Lab 05 giugno 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 34 volte e gli è piaciuto 0 spettatori. Buona visione!