Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > Visual Studio 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 7th, 2008, 06: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

Reply With Quote
  #2 (permalink)  
Old August 7th, 2008, 10: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
Reply With Quote
  #3 (permalink)  
Old August 7th, 2008, 09: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...

Reply With Quote
  #4 (permalink)  
Old August 7th, 2008, 09: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
Reply With Quote
  #5 (permalink)  
Old August 7th, 2008, 09: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.

Reply With Quote
  #6 (permalink)  
Old August 7th, 2008, 09: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?

Reply With Quote
  #7 (permalink)  
Old August 7th, 2008, 10: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
Reply With Quote
  #8 (permalink)  
Old August 7th, 2008, 10: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?

Reply With Quote
  #9 (permalink)  
Old August 8th, 2008, 11: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...

Reply With Quote
  #10 (permalink)  
Old August 8th, 2008, 04: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
Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the directory of app.config cczhangjm C# 2 May 28th, 2007 03:55 AM
How to access app.config in C# ? cczhangjm XML 2 May 16th, 2007 08:43 PM
configure web.config (db details) when deploy app? benilpj ASP.NET 2.0 Basics 3 June 7th, 2006 10: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 07:36 AM



All times are GMT -4. The time now is 04:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.