If cnn.State = ConnectionState.Closed Then
cnn.Open()
End If
يه مثال ميزنم فكر كنم كافي باشه:
کد:If cnn.State = ConnectionState.Closed Then cnn.Open() End If
cnn يك شي از كلاس SqlConnection هست
if (myConnection.State == ConnectionState.Open)
myConnection.Close();