DB Connection in Config.web using VB calls.

StuartD

New Member
Hi all,<BR><BR>All demos in the quickstart have a connection string right in the<BR>Page_Onload sub. In the portal example this uses a config.web key that each<BR>page can then call the connection string by a Key instead of embedding the<BR>connection string in each page. This example in the portal example is done<BR>in c#. This is my 1st attempt to do this in VB and hit a brick wall.<BR><BR>In asp applications, I put in the global.asa (which all we know is nice and<BR><BR>secure....HAHA) and had an include file that called the application root<BR>that was set in global.asa on top of each page. Am I going about this the<BR>wrong way? Below is the config.web, page i&#039m using, Error i&#039m getting and<BR>what the compiler spits out<BR><BR><BR>steve schofield<BR>[email protected]<BR><BR>Webmaster<BR>http://aspfree.com<BR><BR><BR><BR>Here is my config.web<BR><BR><configuration><BR> <security><BR> <authorization><BR> <allow users="*" /> <!-- Allow all (other) users --><BR> </authorization><BR> </security><BR> <configsections><BR> <add name="aspfreedsn"<BR>type="System.Web.Configuration.DictionarySectionHandler"/><BR> </configsections><BR> <aspfreedsn><BR> <set key="aspfreedsn"<BR>value=http://aspmessageboard.com/archive/index.php/"server=localhost;uid=connID;pwd=Password;database= devDB" /><BR> </aspfreedsn><BR></configuration><BR><BR><BR><BR>Page that I&#039m trying to use.<BR><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="System.Data.SQL" %><BR><BR><html><BR><script language="VB" runat="server"><BR><BR> Sub Page_Load(Sender As Object, E As EventArgs)<BR><BR> Dim DS As DataSet<BR> Dim MyConnection As SQLConnection<BR> Dim MyCommand As SQLDataSetCommand<BR><BR> String mydsn = (String) ((Hashtable)<BR>Context.GetConfig("aspfreedsn"))("devDB")<BR> MyConnection = New SQLConnection(mydsn)<BR> MyCommand = New SQLDataSetCommand("select * from tblSiteName",<BR>MyConnection)<BR> DS = New DataSet()<BR> MyCommand.FillDataSet(DS, "tblSiteName")<BR><BR> MyDataList.DataSource = DS.Tables("tblSiteName").DefaultView<BR> MyDataList.DataBind()<BR> End Sub<BR></script><BR><BR><BR><body><BR><BR><ASP:DataList id="MyDataList" runat="server"><BR> RepeatColumns="2"<BR> RepeatDirection="Horizontal"<BR> ItemStyle-Font-Size="10pt"<BR> ItemStyle-Font-Name="Verdana"<BR></ASP:DataList><BR></body><BR></html><BR><BR><BR>Error I&#039m getting<BR><BR>Syntax Error:<BR><BR><BR>Line 11: Dim MyCommand As SQLDataSetCommand<BR>Line 12:<BR>Line 13: String mydsn = (String) ((Hashtable)<BR>Context.GetConfig("aspfreedsn"))("devDB")<BR>Line 14: MyConnection = New SQLConnection(mydsn)<BR>Line 15: MyCommand = New SQLDataSetCommand("select * from<BR>tblSiteName", MyConnection)<BR><BR><BR><BR>Here is what the compiler spits out<BR><BR>C:WINNTsystem32> "vbc.exe" /t:library<BR>/R:"C:WINNTComPlusv2000.14.1812System.Drawing.DLL"<BR>/R:"C:WINNTComPlusv2000.14.1812System.Text.RegularExpr essions.DLL"<BR>/R:"C:WINNTComPlusv2000.14.1812System.DLL"<BR>/R:"C:WINNTComPlusv2000.14.1812System.Web.DLL"<BR>/R:"C:WINNTComPlusv2000.14.1812System.Data.DLL"<BR>/R:"C:WINNTComPlusv2000.14.1812System.Web.Services.DLL"<BR>/R:"C:WINNTComPlusv2000.14.1812System.Xml.Serializatio n.DLL"<BR>/out:"c:inetpubwwwroot estcodegengen2292.dll" /optionexplicit- /debug-<BR>"c:inetpubwwwroot estcodegengen2292.freehosts_aspx.vb"<BR><BR>Microsoft (R) Visual Basic Compiler Version 7.00.8905 [NGWS version<BR>2000.14.1812.10]<BR>Copyright (C) Microsoft Corp 2000. All rights reserved.<BR><BR>c:inetpubwwwroot estfreehosts.aspx(13) : error BC30035: Syntax error<BR><BR> String mydsn = (String) ((Hashtable)<BR>Context.GetConfig("aspfreedsn"))("devDB")<BR> ~~~~~~<BR><BR><BR><BR><BR>Hey Steve, I put a reply up on ASPFree.com http://www.aspfree.com/discuss_aspplus/GetMessage.asp?RootID=6214&ID=6216<BR>______________________________________<BR>Don R. Wolthuis, MCSD<BR>CodeJunkies.Net / ASPNextGen.com<BR>[email protected]<BR><BR>Visit www.ASPNextGen.com or www.theFutureOfASP.com, both brought to you exclusively by CodeJunkies.Net, for tutorials and information on ASP+ - the next generation of Active Server Pages.<BR><BR>http://www.codejunkies.net
 
Back
Top