none
connection stay open RRS feed

  • Question

  • why my connection stay open but if I insert 

    data entered into the database

     

    Imports System.Data.OleDb

    Imports System.Data

     

    Module Mdglobal

        Public koneksi As String

        Public sqlconn As New OleDbConnection

        Public strSQL As String

        Public oDR As System.Data.OleDb.OleDbDataReader

        Public ocmd As New System.Data.OleDb.OleDbCommand

     

        Public Sub koneksikeSQL()

            Try

                sqlconn.Open()

            Catch ex As Exception

                sqlconn.Close()

            End Try

     

            sqlconn.ConnectionString = "provider = SQLOLEDB; Data Source=(local)\SQLEXPRESS;Initial Catalog=toko;Integrated Security=SSPI"

     

            Try

                sqlconn.Open()

            Catch ex As Exception

                MessageBox.Show("Koneksi gagal")

            End Try

        End Sub

        Public Sub TutupKoneksiSQL()

            sqlconn.Close()

        End Sub

     

    End Module


    adulyajed
    Wednesday, July 27, 2011 4:37 AM

Answers

  •     Try

                sqlconn.Open()

            Catch ex As Exception

     

            End Try

     Finally

      sqlconn.Close()


    Best Regards,
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Marked as answer by Adulyajed Wednesday, July 27, 2011 5:34 AM
    Wednesday, July 27, 2011 5:02 AM