0

I am using the following code to retrieve the last entered value from a table and insert it into a textbox called rf.

The code below works but the DB remains open until I restart my computer.

Sub Page_Load()

If Request.QueryString("VesselName") Is Nothing Then
            VesselName.Text = "Blank Name" 'some default value
        Else
            VesselName.Text = Request.QueryString("VesselName")

        End If
		
		'construct the command object and open a connection to the Returns table
        Dim dbconn, sql, dbcomm, dbread
        dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("AnnexII.mdb"))

        dbconn.Open()
        sql = "SELECT Ref FROM Returns WHERE VesselName = '" & Trim(VesselName.Text) & "'"

       
        dbcomm = New OleDbCommand(sql, dbconn)
        dbread = dbcomm.ExecuteReader()


        If dbread.Read Then
            rf.Text = dbread(0)


            dbread.Close()

            dbconn.Close()
	
       End If

	   

End Sub
</script>

THanks ViRiPuFF

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by ViRiPuFF
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.