 |
BOOK: Beginning ASP.NET 1.0  | This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 1.0 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
|
|
|
|
|

August 7th, 2004, 06:50 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Object reference Error
Hello,
I am getting this error when I run my code, it complies ok.
System.NullReferenceException: Object reference not set to an instance of an object
---------------------------
Here is my code for my class:
Imports Microsoft.Win32
Imports System.Data
Public Class clsConnectionString
Public Function GetConnectionString(ByVal strConnID As String) As String
'define objects
Dim objRegistryKey As RegistryKey
Dim objDatabase As Object
'define variables
Dim ConnectionStringArea As String = "SOFTWARE\MyApp\"
Dim strConnectionPath As String = ConnectionStringArea & strConnID
'set object to string in registry & return string value
objRegistryKey = Registry.LocalMachine.OpenSubKey(strConnectionPath , False)
objDatabase = objRegistryKey.GetValue("strConnID")
Return Convert.ToString(GetConnectionString(objDatabase))
End Function
End Class
-------------------------------
I get the error on the "RED" line in my code.
Any help with this is greatly appreciated, I been at this now for 2 days and can get anywhere with it.
Thanks in advance,
Mark
|
|

August 8th, 2004, 04:19 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
It means that in the Software\MyApp\ folder, it can't find "strConnID" key in the registry. I think you need to specify HKey Local Machine\Software\MyApp
Brian
|
|

August 8th, 2004, 07:58 PM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks again Brain,
I think it may have been a typing mistake I my behalf.
The line:
objRegistryKey = Registry.LocalMachine.OpenSubKey(strConnectionPath , False) lets the program know where the "Software\MyApp" is. My mistake however was there my registry string is called ConnectionSource NOT ConnectionString..
Thanks for your help.
Mark
|
|

August 9th, 2004, 06:39 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Does anyone know what to put in the registry for a connection string, what mean is, how do you type it?
Thanks,
Mark
|
|

August 9th, 2004, 07:29 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
Your right, I apologize, I missed that line. Right-click to add a new string value. Enter in the name ConnectionSource, then double-click it and copy/paste your connection string there.
Brian
|
|
 |