.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 26th, 2000, 10:24 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
DB Connection in Config.web using VB calls.

<i><b>Originally posted by : steve schofield (steve@aspfree.com)</b></i><br />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'm using, Error i'm getting and<br />what the compiler spits out<br /><br /><br />steve schofield<br />steve@aspfree.com<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="server=localhost;uid=connID;pwd=Password;database= devDB" /><br /> </aspfreedsn><br /></configuration><br /><br /><br /><br />Page that I'm 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 /><ASPataList id="MyDataList" runat="server"><br /> RepeatColumns="2"<br /> RepeatDirection="Horizontal"<br /> ItemStyle-Font-Size="10pt"<br /> ItemStyle-Font-Name="Verdana"<br /></ASPataList><br /></body><br /></html><br /><br /><br />Error I'm 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 /><br />

Reply With Quote
  #2  
Old August 27th, 2000, 06:39 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
<i><b>Originally posted by : D. R. Wolthuis (don.wolthuis@codejunkies.net)</b></i><br />How's it going? There was a couple things I found wrong. I put comments near the problem areas. It's kind of late so I may have made some spelling mistakes, I'll take another look in the morning to make sure I didn't leave anything out! Let me know if this works.<br /><br />______________________________________<br />Don R. Wolthuis, MCSD<br />CodeJunkies.Net / ASPNextGen.com<br />don.wolthuis@codejunkies.net<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<br /><br /><br /><br /><br /><br /><configuration><br /><security><br /><authorization><br /><allow users="*" /> <!-- Allow all (other) users --><br /></authorization><br /></security><br /><br /><configsections><br /><!-- Missing a space after quote at the end, and 'You had your key and name the same I changed it to aspfreeConfig.--><br /> <add name="aspfreeConfig" type="System.Web.Configuration.DictionarySectionHandler" /> <br /></configsections><br /><br /><aspfreeConfig><br /><!-- I have seen set key and add key in this section so if it still doesn't work try add key--><br /><br /><set key="aspfreedsn"<br />value="server=localhost;uid=connID;pwd=Password;database= devDB" /><br /></aspfreeConfig><br /><br /></configuration><br /><br /><br /><br /><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 />'The DictionarySectionHandler returns a Hashtable so we create one.<br /> Dim htDSNInfo As Hashtable = Context.GetConfig("aspfreeConfig")<br /> <br />'Then access the key to return the value<br /> Dim mydsn = CStr(htDSNInfo("aspfreedsn") <br /><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 /><ASPataList id="MyDataList" runat="server"><br />RepeatColumns="2"<br />RepeatDirection="Horizontal"<br />ItemStyle-Font-Size="10pt"<br />ItemStyle-Font-Name="Verdana"<br /></ASPataList><br /></body><br /></html><br /><br /><br /><br />------------<br />steve schofield at 8/26/2000 8:24:37 PM<br /><br />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'm using, Error i'm getting and<br />what the compiler spits out<br /><br /><br />steve schofield<br />steve@aspfree.com<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="server=localhost;uid=connID;pwd=Password;database= devDB" /><br /> </aspfreedsn><br /></configuration><br /><br /><br /><br />Page that I'm 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 /><ASPataList id="MyDataList" runat="server"><br /> RepeatColumns="2"<br /> RepeatDirection="Horizontal"<br /> ItemStyle-Font-Size="10pt"<br /> ItemStyle-Font-Name="Verdana"<br /></ASPataList><br /></body><br /></html><br /><br /><br />Error I'm 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 /><br />

Reply With Quote
  #3  
Old August 27th, 2000, 10:09 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
<i><b>Originally posted by : D. R. Wolthuis (don.wolthuis@codejunkies.net)</b></i><br />I knew I made an error.<br />This: <br />'Then access the key to return the value<br /><br /> Dim mydsn = CStr(htDSNInfo("aspfreedsn") <br /><br />Should be this:<br /><br />'Then access the key to return the value<br /> Dim mydsn as String = CStr(htDSNInfo("aspfreedsn")) <br /><br /><br />______________________________________<br />Don R. Wolthuis, MCSD<br />CodeJunkies.Net / ASPNextGen.com<br />don.wolthuis@codejunkies.net<br /><br />------------<br />D. R. Wolthuis at 8/27/2000 4:39:50 AM<br /><br />How's it going? There was a couple things I found wrong. I put comments near the problem areas. It's kind of late so I may have made some spelling mistakes, I'll take another look in the morning to make sure I didn't leave anything out! Let me know if this works.<br /><br />______________________________________<br />Don R. Wolthuis, MCSD<br />CodeJunkies.Net / ASPNextGen.com<br />don.wolthuis@codejunkies.net<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<br /><br /><br /><br /><br /><br /><configuration><br /><security><br /><authorization><br /><allow users="*" /> <!-- Allow all (other) users --><br /></authorization><br /></security><br /><br /><configsections><br /><!-- Missing a space after quote at the end, and 'You had your key and name the same I changed it to aspfreeConfig.--><br /> <add name="aspfreeConfig" type="System.Web.Configuration.DictionarySectionHandler" /> <br /></configsections><br /><br /><aspfreeConfig><br /><!-- I have seen set key and add key in this section so if it still doesn't work try add key--><br /><br /><set key="aspfreedsn"<br />value="server=localhost;uid=connID;pwd=Password;database= devDB" /><br /></aspfreeConfig><br /><br /></configuration><br /><br /><br /><br /><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 />'The DictionarySectionHandler returns a Hashtable so we create one.<br /> Dim htDSNInfo As Hashtable = Context.GetConfig("aspfreeConfig")<br /> <br />'Then access the key to return the value<br /> Dim mydsn = CStr(htDSNInfo("aspfreedsn") <br /><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 /><ASPataList id="MyDataList" runat="server"><br />RepeatColumns="2"<br />RepeatDirection="Horizontal"<br />ItemStyle-Font-Size="10pt"<br />ItemStyle-Font-Name="Verdana"<br /></ASPataList><br /></body><br /></html><br /><br /><br /><br />------------<br />steve schofield at 8/26/2000 8:24:37 PM<br /><br />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'm using, Error i'm getting and<br />what the compiler spits out<br /><br /><br />steve schofield<br />steve@aspfree.com<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="server=localhost;uid=connID;pwd=Password;database= devDB" /><br /> </aspfreedsn><br /></configuration><br /><br /><br /><br />Page that I'm 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 /><ASPataList id="MyDataList" runat="server"><br /> RepeatColumns="2"<br /> RepeatDirection="Horizontal"<br /> ItemStyle-Font-Size="10pt"<br /> ItemStyle-Font-Name="Verdana"<br /></ASPataList><br /></body><br /></html><br /><br /><br />Error I'm 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 /><br />

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > DB Connection in Config.web using VB calls.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek