Hello there....<BR><BR>Need some help. I will be having many sub routines which will perform different DB queries based on buttons pushed on the web page. How do I set things up so that I don't have to create, open and close, connections to the same database in every routine? Here's the code I have so far. You should be able to see my delimma.<BR><BR><%@ import namespace="system.data.oledb" %><BR><%@ import namespace="system.data" %><BR><script language="vb" runat="server"><BR><BR>sub page_load(sender as object, e as eventargs)<BR><BR> If Not Page.IsPostBack Then<BR> <BR> const connection_string as string = "PROVIDER=SQLOLEDB; Data Source=w2ksvs2; Initial Catalog=cddatabase; User ID=; Password=;"<BR> dim objconn as new oledbconnection(connection_string)<BR> dim objcmd as new oledbcommand<BR> <BR> objconn.open()<BR> objcmd = new oledbcommand("software_genre", objconn)<BR> <BR> dim data_reader as oledbdatareader<BR> data_reader = objcmd.executereader()<BR> <BR> cbxgenre.datasource = data_reader<BR> cbxgenre.databind()<BR> <BR> data_reader.close() <BR> objconn.close()<BR> <BR> end if<BR><BR>end sub<BR><BR>sub genre_search(sender as object, e as eventargs)<BR><BR> const connection_string as string = "PROVIDER=SQLOLEDB; Data Source=w2ksvs2; Initial Catalog=cddatabase; User ID=; Password=;"<BR> dim objconn as new oledbconnection(connection_string)<BR> dim objcmd as new oledbcommand<BR> dim strsql as string<BR> <BR> objconn.open()<BR> <BR> strsql = "select * from software where software_genre = '" & cbxgenre.SelectedItem.Text & "'"<BR> <BR> objcmd = new oledbcommand(strsql,objconn)<BR> <BR> datagrid1.datasource = objcmd.executereader()<BR> datagrid1.databind()<BR> <BR> objconn.close<BR><BR>end sub<BR><BR><BR></script><BR><BR><html><BR> <body><BR> <form runat="server"><BR> <aspropDownList id="cbxgenre" runat="server" DataTextField="software_genre" DataValueField="software_genre"></aspropDownList><BR> <asp:Button Runat=server Text=Search OnClick=genre_search></asp:Button><BR> <BR> <aspataGrid id="DataGrid1" runat="server" /><BR> </form><BR> </body><BR></html><BR>See, when the page is visited the first time, the Page's load event fires and the Page_Load event handler is run. So there, you say, "If I'm not a postback, open up a database connection, do some data binding, and close the database connection." This is great, this is what you want to do. Now, say the user then chooses a particular subcategory, then the page will be resubmitted to the Web server with information that the search button has been clicked. This will cause the genre_search event handler to run and there you want to do exactly what you do - open a database connection, do a specific SQL query, etc.<BR><BR>Now, if you want to modularize some of this code, you can put the connection string portion into a confirugationSection in the Web.config file.<BR><BR>hthThank you for your response. It just seemed to me that this would cause a bunch of redundant code, but I can see how it may be better and more secure to do it this way. Thanks again for your help!