VB.NET and SQL Server - How to Update data in SQL Server Database using Vb.net.

Опубликовано: 05 Июнь 2020
на канале: VB Programming Lab
34
0

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


Смотрите видео VB.NET and SQL Server - How to Update data in SQL Server Database using Vb.net. онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь VB Programming Lab 05 Июнь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 34 раз и оно понравилось 0 людям.