Thread: Survey Engine
View Single Post
  #3 (permalink)  
Old March 3rd, 2008, 02:30 AM
Dennis239 Dennis239 is offline
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. Of course what you posted is better. And to be honest I can't believe Imar wrote Chapters 4 and 7 (I haven't read the remainder yet). Take this function from Capter 7 - Photogallery
Code:
    Public Shared Function InsertCollection(ByVal pc As PhotoCollection) As Boolean

        Try

            Dim conn As New SqlConnection()
            Dim cmd As New SqlCommand()
            conn.ConnectionString = PhotoDB.ConnectionString
            cmd.Connection = conn
            conn.Open()
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "add_collection"

            ' Create a SqlParameter for each parameter in the stored procedure.
            Dim nameParam As New SqlParameter("@name", pc.name)
            Dim descParam As New SqlParameter("@desc", pc.description)
            cmd.Parameters.Add(nameParam)
            cmd.Parameters.Add(descParam)

            cmd.ExecuteNonQuery()

            Return True

        Catch ex As Exception


            Throw (ex)

        End Try

    End Function
Where connection is closed?
Code:
Catch ex As Exception


      Throw (ex)

End Try
What is this?