Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 7th, 2008, 05:04 AM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default web.config vs. app.config

Hi, i juz wanted to know how to write this following codings in app.config.

In ASP.Net in web.config:
     <configuration>
          <appSettings>
                <add key = "stu" value = "database = Gred; trusted_connection = yes; server = (local)">
          </appSettings>
     </configuration>

N in codings part:
Imports System.Data.SqlConnection
Dim con As New SqlConnection (ConfigurationSetting.AppSettings("stu"))

Now how to do the same thing in VB.Net(app.Settings)

I tried app.config:
<configuration>
     <appSettings>
          <add key = "stu.ConnectionString" value = "datasource = Gred; initial catalog = Apps; Integrated Security = SSPI; packet size = 4096"/>
     </appSettings>
</configuration>

N in codings part:

Imports System.Data.SqlClient
Me.stu.ConnectionString = CType (System.Configuration.ConfigurationSettings.AppSet tings.GetValues("stu.ConnectionString"))

ASP.Net is not a prob but how to do the same thing in vb.net. The above codes was taken in net but doesnt work. Help me please... n plz do xplain d codes 2...:D

  #2 (permalink)  
Old August 7th, 2008, 09:05 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can you explain how it doesn't work?

Is is crashing? Returning an empty string?

-Peter
compiledthoughts.com
  #3 (permalink)  
Old August 7th, 2008, 08:27 PM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It says 'syntax error' for
[u]Me</u>.stu.ConnectionString = CType (System.Configuration.ConfigurationSettings.AppSet tings.GetValues("stu.ConnectionString"))

So i tried this code
sysmgr.stu.ConnectionString = CType (System.Configuration.ConfigurationSettings.AppSet tings.GetValues("stu.ConnectionString"))

sysmgr is my forms name, n it stil shows error...

  #4 (permalink)  
Old August 7th, 2008, 08:35 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Without seeing the code for the forms in question I can't say for sure what the problem is. You need to ensure that you can assign a value to the properties to which you are attempting to assign values. What is the "stu" property? Is that a database connection?

-Peter
compiledthoughts.com
  #5 (permalink)  
Old August 7th, 2008, 08:42 PM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

S, "stu" is a database connection.

  #6 (permalink)  
Old August 7th, 2008, 08:51 PM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

BTW wht initial catalog=Apps n packet size=4096 means or stand for?

  #7 (permalink)  
Old August 7th, 2008, 09:18 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Initial catalog is the database that the connection is working against.
I imagine that packet size is the size of the packets used in the connection communications. I wouldn't worry about that one too much.

-Peter
compiledthoughts.com
  #8 (permalink)  
Old August 7th, 2008, 09:40 PM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So the packet size=4096 wil be vary or juz make it same for vry project?

  #9 (permalink)  
Old August 8th, 2008, 10:49 AM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Any1 found my mistake?

Im usin visual studio 2005, hop this helps...

  #10 (permalink)  
Old August 8th, 2008, 03:56 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Honestly, I never see that in any connection strings I use. I don't think it's critical. I'm sure there are performance implications and you can use that to tune the TCP/IP connection if you know how to do that. I would just omit it and not worry about it.

-Peter
compiledthoughts.com




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the directory of app.config cczhangjm C# 2 May 28th, 2007 02:55 AM
How to access app.config in C# ? cczhangjm XML 2 May 16th, 2007 07:43 PM
configure web.config (db details) when deploy app? benilpj ASP.NET 2.0 Basics 3 June 7th, 2006 09:27 PM
Chapter 8 - app.config jotto BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 March 21st, 2006 05:31 PM
Best way to bind config data to a web app psantos Pro JSP 2 October 21st, 2003 06:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.