none
Visual Studio 2010, VB, and database connections RRS feed

  • General discussion

  • I am new to VB and VS 2010 but have been able to figure most things out in general. I do have a quick question, though...

    I am starting to build an application with a MySQL backend. Form1 is my login form that checks against a "users" table in my database. This works fine and Form2 displays when I have successfully authenticated.

    My question is this: if I don't close the database connection explicitly (conn.close()), does that connection stay open for Form2..Form3, Form4, etc to where I can simply run my next query? Or is it simply best practice to close the connection from form to form and simply declare and open another connection?

    Many thanks ahead of time for helping me learn!

    Friday, September 28, 2012 5:12 PM

All replies

  • Hello HSSNE,

    I am new to VB and VS 2010 but have been able to figure most things out in general. I do have a quick question, though...

    I am starting to build an application with a MySQL backend. Form1 is my login form that checks against a "users" table in my database. This works fine and Form2 displays when I have successfully authenticated.

    My question is this: if I don't close the database connection explicitly (conn.close()), does that connection stay open for Form2..Form3, Form4, etc to where I can simply run my next query? Or is it simply best practice to close the connection from form to form and simply declare and open another connection?

    Many thanks ahead of time for helping me learn!

    practice would be to keep the connection to the DataBase and open only when necessary and close subuto after performing all operations vesro it, because even leave an open connection and unnecessary, and it even at the expense of the waste of resources by the operating system .

    Regards.


    Friday, September 28, 2012 7:13 PM