Variable XYZ is used before it has been assigned a value
Sometimes you fall in the condition where you might require to put try and catch block after just declaring variable ad that creates warning that Variable XYZ is used before it has been assigned a value.
The simple solution is , assign Nothing to the variable and check on the catch side.:
Dim BookingTran As Common.DbTransaction = Nothing Try Dim db As Database = DatabaseFactory.CreateDatabase(Config.BookingDBName) BookingConn = db.CreateConnection BookingConn.Open() BookingTran = BookingConn.BeginTransaction() Catch If Not BookingTran Is Nothing Then BookingTran.Rollback() End If End Try