I have a windows application with a start button on the main screen. Once I start the exe and hit the start button, a connection to the SQL database is opened. I am not explicitly closing the connection at any point of time unless it closes by itself, whereby I reestablish the connection to the db. My question is will this cause any performance issues? I doubt that, since only one connection at any point of time is open. Please advice. Thanks in advance.
The code is as below:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 30000
fnDbConnect()
lblMessage.Text = ""
End Sub
Private Sub btnStartSMS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartSMS.Click
btnStartSMS.BackColor = Color.Red
If ObjCn.State = ConnectionState.Open Then
Timer1.Enabled = True
Else
If fnDbConnect() Then
Timer1.Enabled = True
Else
MsgBox("An error occured while connecting to database. Please try later", MsgBoxStyle.Critical)
End If
End If
End Sub
And ObjCn.State = ConnectionState.Closed is checked wherever application and it is True, then fnDbConnect() is called.