Author: ktlau859 | Posted on: 12/10/2008 3:18:28 AM | Views : 295

Hi all,
I'm developing ASP.NET 2.0 applications using VB2005 under Visual Studio 2005 environment.
I've defined a connection string (<add name "con_str" etc.) in the web.config, and try to retrieve it in aspx.vb code as follow:
1. first I define a private function for retrieval of the connection string as follow:
Private Shared Function getConnectionString() As String
        Return ConfigurationManager.ConnectionStrings("con_str").ConnectionString
End Function
2. then I start a new connection in my code with the following:
Dim objConn As New SqlConnection(getConnectionString)
however, I got the following error when I run the code:
 "Use the new keyword to create a new object instance" 
Can anyone tell me what's wrong with my code?
Tony

...

Go to the complete details ...