Private Sub UpdateTest()
Try
Dim SqlCmd As SqlCommand
Dim SqlCon As SqlConnection
Dim strConString As String
Dim SqlQuery As String = String.Empty
strConString = System.Configuration.ConfigurationManager.ConnectionStrings("Cn").ConnectionString
SqlQuery = "UPDATE Staff SET TEST='HI' WHERE ID = 12"
SqlCon = New SqlConnection(strConString)
SqlCmd = New SqlCommand(SqlQuery, SqlCon)
SqlCon.Open()
SqlCmd.ExecuteNonQuery()
SqlCon.Close()
SqlCmd.Dispose()
SqlCon.Dispose()
Catch ex As Exception
lblMsg.Text = "Error"
Finally
SqlCon.Close()
SqlCmd.Dispose()
SqlCon.Dispose()
End Try
End Sub
Try
Dim SqlCmd As SqlCommand
Dim SqlCon As SqlConnection
Dim strConString As String
Dim SqlQuery As String = String.Empty
strConString = System.Configuration.ConfigurationManager.ConnectionStrings("Cn").ConnectionString
SqlQuery = "UPDATE Staff SET TEST='HI' WHERE ID = 12"
SqlCon = New SqlConnection(strConString)
SqlCmd = New SqlCommand(SqlQuery, SqlCon)
SqlCon.Open()
SqlCmd.ExecuteNonQuery()
SqlCon.Close()
SqlCmd.Dispose()
SqlCon.Dispose()
Catch ex As Exception
lblMsg.Text = "Error"
Finally
SqlCon.Close()
SqlCmd.Dispose()
SqlCon.Dispose()
End Try
End Sub
No comments:
Post a Comment