Click here to Skip to main content
15,920,383 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralHelp with security Pin
axehead6917-Aug-04 20:34
axehead6917-Aug-04 20:34 
GeneralRe: Help with security Pin
Dave Kreskowiak18-Aug-04 3:47
mveDave Kreskowiak18-Aug-04 3:47 
GeneralQuestion regarding Garbage Collector Pin
AstronusX17-Aug-04 12:38
AstronusX17-Aug-04 12:38 
GeneralRe: Question regarding Garbage Collector Pin
S Sansanwal17-Aug-04 13:43
S Sansanwal17-Aug-04 13:43 
GeneralDatabase repair Pin
benjj17-Aug-04 11:23
benjj17-Aug-04 11:23 
GeneralRe: Database repair Pin
Dave Kreskowiak18-Aug-04 3:37
mveDave Kreskowiak18-Aug-04 3:37 
Generalsilly exception question Pin
kowplunk17-Aug-04 10:34
kowplunk17-Aug-04 10:34 
GeneralRe: silly exception question Pin
Dave Kreskowiak18-Aug-04 3:30
mveDave Kreskowiak18-Aug-04 3:30 
kowplunk wrote:
conn.open 'not sure if this has to be in the t/c block
someDAMethod()
conn.close 'connection should still be closed, right?


Actually, your connection code should be in your someDAmethod code, not on your form. This way, your connection is handled where it belongs, in your Data Access method. In there, your connection can be closed in the Try/Catch/Finally block (inside Finally). It would go something like this:
Try
    ' setup our database connection.
    Dim conn As SqlConnection = GetConnection()
    Dim comm As New SqlCommand("blaa blaa blaa")
    Dim param As New SqlParameter(blaa blaa blaa)
    .
    .
    (more code to setup and execute our data access)
Catch ex As Exception
    ' Code to log the exception, throw a custom exception, or whatever to handle a failed request.
Finally
    ' Check to see if the connection is anything but closed!  Don't check for Open!
    If conn.State <> ConnectionState.Closed Then
        conn.Close()
    End If
    comm = Nothing
    conn.Dispose()
End Try



RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralRe: silly exception question Pin
kowplunk18-Aug-04 4:11
kowplunk18-Aug-04 4:11 
GeneralReading data from a printer Pin
tpiotr17-Aug-04 8:41
tpiotr17-Aug-04 8:41 
GeneralRe: Reading data from a printer Pin
Dave Kreskowiak18-Aug-04 3:16
mveDave Kreskowiak18-Aug-04 3:16 
Generalthe system speaker Pin
udi3217-Aug-04 8:29
udi3217-Aug-04 8:29 
GeneralRe: the system speaker Pin
Daniel Turini17-Aug-04 9:40
Daniel Turini17-Aug-04 9:40 
GeneralRe: the system speaker Pin
udi3219-Aug-04 14:07
udi3219-Aug-04 14:07 
Questionis this VBA? Pin
Pablo.ar17-Aug-04 6:51
Pablo.ar17-Aug-04 6:51 
AnswerRe: is this VBA? Pin
Dave Kreskowiak17-Aug-04 10:32
mveDave Kreskowiak17-Aug-04 10:32 
GeneralRe: is this VBA? Pin
Pablo.ar17-Aug-04 16:12
Pablo.ar17-Aug-04 16:12 
QuestionHow to close child windows?? Pin
viettho17-Aug-04 6:15
viettho17-Aug-04 6:15 
AnswerRe: How to close child windows?? Pin
Dave Kreskowiak17-Aug-04 10:29
mveDave Kreskowiak17-Aug-04 10:29 
Generalimporting fortran dll's Pin
alankrita17-Aug-04 5:54
alankrita17-Aug-04 5:54 
GeneralRe: importing fortran dll's Pin
Dave Kreskowiak17-Aug-04 10:26
mveDave Kreskowiak17-Aug-04 10:26 
GeneralRe: importing fortran dll's Pin
progload17-Aug-04 15:19
progload17-Aug-04 15:19 
GeneralRe: importing fortran dll's Pin
progload17-Aug-04 15:24
progload17-Aug-04 15:24 
GeneralwaveOutGetDevCaps Pin
mivey417-Aug-04 5:14
mivey417-Aug-04 5:14 
GeneralRe: waveOutGetDevCaps Pin
Dave Kreskowiak17-Aug-04 5:37
mveDave Kreskowiak17-Aug-04 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.