define global value

N

.nLL

hi, im new to asp.net and trying to define a global value. i dont want to
use web.config because i want to be able to run my app on any sub folder
without created an application in iis.

so far i got below in my functons.vb

------------------------
Public Class MyFunctions
Public Shared Function MyDbPath() As String
Return "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|bookmarks.mdb;User Id=admin;Password=;"
End Function


Public Shared Function AlphaNumOnly(ByVal MyString As String) As String
Dim sResult As String
sResult = Trim(MyString)
If Not sResult = "" Then
sResult = Regex.Replace(MyString, "[^a-z|A-Z|0-9|\.|\-]{1,50}",
"")
End If

Return sResult
End Function
end class
----------------------------------------------

i can use AlphaNumOnly function anywhere within my code and works fine but
when i try to use myfunctions.MyDbPath() i get error saying ' MyDbPath is
not member of MYNameSpace.Myfunctions

I can;t see what im doing wrong.

thanks
 
J

Jonathan Wood

Although I use C# and may potentually miss some nuances of VB.NET, I don't
see the difference. I suspect that the problem is somewhere other than the
code you posted. Let's see the reference that fails and the exact error
message.
 
N

.nLL

thanks for reply. here is the ful error
--------------------------------------

Server Error in '/WebApplication1' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30456: 'MyDbPath' is not a member of
'MyBookmarks.MyFunctions'.

Source Error:



Line 23: Dim MySql As String
Line 24: MySql = "SELECT folder FROM bookmark Where un='" & MyUn &
"' and not folder='top' GROUP by folder order by folder asc"
Line 25: Dim Conn As New OleDbConnection(MyFunctions.MyDbPath)
Line 26: Dim Cmd As New OleDbCommand(MySql, Conn)
Line 27: Dim objDR As OleDbDataReader


Source File:
C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx
Line: 25



Show Detailed Compiler Output:


C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>
"C:\Windows\Microsoft.NET\Framework\v3.5\vbc.exe" /t:library /utf8output
/R:"C:\Windows\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll"
/R:"C:\Windows\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll"
/R:"C:\Windows\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\assembly\dl3\d1acef42\2bd118b4_6105c901\MyBookmarks.DLL"
/out:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\App_Web_altn4mxt.dll" /D:DEBUG=1
/debug+ /define:_MYTYPE=\"Web\"
/imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Linq,System.Xml.Linq,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls
/warnaserror- /optionInfer+
"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\App_Web_altn4mxt.0.vb"
"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\App_Web_altn4mxt.1.vb"


Microsoft (R) Visual Basic Compiler version 9.0.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.

C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx(25)
: error BC30456: 'MyDbPath' is not a member of 'MyBookmarks.MyFunctions'.

Dim Conn As New OleDbConnection(MyFunctions.MyDbPath)
~~~~~~~~~~~~~~~~~~~~





Show Complete Compilation Source:


Line 1:
#ExternalChecksum("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx","{406ea660-64cf-4c82-b6f0-42d48172a799}","212C28A61811E34E1121B6B0A9ACE78F")
Line 2:
'------------------------------------------------------------------------------
Line 3: ' <auto-generated>
Line 4: ' This code was generated by a tool.
Line 5: ' Runtime Version:2.0.50727.3053
Line 6: '
Line 7: ' Changes to this file may cause incorrect behavior and will
be lost if
Line 8: ' the code is regenerated.
Line 9: ' </auto-generated>
Line 10:
'------------------------------------------------------------------------------
Line 11:
Line 12: Option Strict Off
Line 13: Option Explicit On
Line 14:
Line 15: Imports Microsoft.VisualBasic
Line 16: Imports MyBookmarks
Line 17: Imports System
Line 18: Imports System.Collections
Line 19: Imports System.Collections.Generic
Line 20: Imports System.Collections.Specialized
Line 21: Imports System.Configuration
Line 22: Imports System.Data.OleDb
Line 23: Imports System.Linq
Line 24: Imports System.Text
Line 25: Imports System.Text.RegularExpressions
Line 26: Imports System.Web
Line 27: Imports System.Web.Caching
Line 28: Imports System.Web.Profile
Line 29: Imports System.Web.Security
Line 30: Imports System.Web.SessionState
Line 31: Imports System.Web.UI
Line 32: Imports System.Web.UI.HtmlControls
Line 33: Imports System.Web.UI.WebControls
Line 34: Imports System.Web.UI.WebControls.WebParts
Line 35: Imports System.Xml.Linq
Line 36:
Line 37: Namespace ASP
Line 38:
Line 39:
<System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()> _
Line 40: Public Class bookmarks_aspx
Line 41: Inherits Global.System.Web.UI.Page
Line 42: Implements System.Web.SessionState.IRequiresSessionState,
System.Web.IHttpHandler
Line 43:
Line 44: Private Shared __initialized As Boolean
Line 45:
Line 46: Private Shared __fileDependencies As Object
Line 47:
Line 48: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 49: Public Sub New()
Line 50: MyBase.New
Line 51: Dim dependencies() As String
Line 52:
CType(Me,Global.System.Web.UI.Page).AppRelativeVirtualPath =
"~/bookmarks.aspx"
Line 53: If (Global.ASP.bookmarks_aspx.__initialized = false)
Then
Line 54: dependencies = New String(0) {}
Line 55: dependencies(0) = "~/bookmarks.aspx"
Line 56: Global.ASP.bookmarks_aspx.__fileDependencies =
Me.GetWrappedFileDependencies(dependencies)
Line 57: Global.ASP.bookmarks_aspx.__initialized = true
Line 58: End If
Line 59: Me.Server.ScriptTimeout = 30000000
Line 60: End Sub
Line 61:
Line 62: Protected ReadOnly Property Profile() As
System.Web.Profile.DefaultProfile
Line 63: Get
Line 64: Return
CType(Me.Context.Profile,System.Web.Profile.DefaultProfile)
Line 65: End Get
Line 66: End Property
Line 67:
Line 68: Protected Overrides ReadOnly Property SupportAutoEvents()
As Boolean
Line 69: Get
Line 70: Return false
Line 71: End Get
Line 72: End Property
Line 73:
Line 74: Protected ReadOnly Property ApplicationInstance() As
System.Web.HttpApplication
Line 75: Get
Line 76: Return
CType(Me.Context.ApplicationInstance,System.Web.HttpApplication)
Line 77: End Get
Line 78: End Property
Line 79:
Line 80: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 81: Private Function __BuildControl__control3() As
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 82: Dim __ctrl As
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 83:
Line 84:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",19)
Line 85: __ctrl = New
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 86:
Line 87: #End ExternalSource
Line 88: Return __ctrl
Line 89: End Function
Line 90:
Line 91: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 92: Private Function __BuildControl__control2() As
Global.System.Web.UI.HtmlControls.HtmlHead
Line 93: Dim __ctrl As
Global.System.Web.UI.HtmlControls.HtmlHead
Line 94:
Line 95:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",18)
Line 96: __ctrl = New
Global.System.Web.UI.HtmlControls.HtmlHead("head")
Line 97:
Line 98: #End ExternalSource
Line 99: Dim __ctrl1 As
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 100:
Line 101:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",18)
Line 102: __ctrl1 = Me.__BuildControl__control3
Line 103:
Line 104: #End ExternalSource
Line 105: Dim __parser As System.Web.UI.IParserAccessor =
CType(__ctrl,System.Web.UI.IParserAccessor)
Line 106:
Line 107:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",18)
Line 108: __parser.AddParsedSubObject(__ctrl1)
Line 109:
Line 110: #End ExternalSource
Line 111: Return __ctrl
Line 112: End Function
Line 113:
Line 114: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 115: Private Sub __BuildControlTree(ByVal __ctrl As
bookmarks_aspx)
Line 116:
Line 117:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",1)
Line 118: Me.InitializeCulture
Line 119:
Line 120: #End ExternalSource
Line 121: Dim __ctrl1 As
Global.System.Web.UI.HtmlControls.HtmlHead
Line 122:
Line 123:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",1)
Line 124: __ctrl1 = Me.__BuildControl__control2
Line 125:
Line 126: #End ExternalSource
Line 127: Dim __parser As System.Web.UI.IParserAccessor =
CType(__ctrl,System.Web.UI.IParserAccessor)
Line 128:
Line 129:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",1)
Line 130: __parser.AddParsedSubObject(__ctrl1)
Line 131:
Line 132: #End ExternalSource
Line 133: __ctrl.SetRenderMethodDelegate(AddressOf
Me.__Render__control1)
Line 134: End Sub
Line 135:
Line 136: Private Sub __Render__control1(ByVal __w As
System.Web.UI.HtmlTextWriter, ByVal parameterContainer As
System.Web.UI.Control)
Line 137:
Line 138:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",5)
Line 139:
Line 140: 'check if user
exist-------------------------------------------------------
Line 141:
'--------------------------------------------------------------------------
Line 142: Dim MyUn As String =
MyFunctions.AlphaNumOnly(Request.QueryString("un"))
Line 143: Dim MyPw As String =
MyFunctions.AlphaNumOnly(Request.QueryString("pw"))
Line 144:
Line 145: If MyFunctions.CheckLogin(MyUn, MyPw) = 0 Then
Line 146: Response.Write("http://google.com")
Line 147: Else
Line 148:
'--------------------------------------------------------------------------
Line 149:
'--------------------------------------------------------------------------
Line 150:
Line 151:
Line 152: #End ExternalSource
Line 153: __w.Write("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML
1.0 Transitional//EN"" ""http://www.w3.org"& _
Line 154:
"/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<html
xmlns=""http://www.w3.org/1999/xh"& _
Line 155: "tml""
>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
Line 156: parameterContainer.Controls(0).RenderControl(__w)
Line 157:
__w.Write(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<body>")
Line 158:
Line 159:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",21)
Line 160:
Line 161:
Line 162: Dim MySql As String
Line 163: MySql = "SELECT folder FROM bookmark Where un='" & MyUn
& "' and not folder='top' GROUP by folder order by folder asc"
Line 164: Dim Conn As New OleDbConnection(MyFunctions.MyDbPath)
Line 165: Dim Cmd As New OleDbCommand(MySql, Conn)
Line 166: Dim objDR As OleDbDataReader
Line 167: Dim folder As String
Line 168: Conn.Open()
Line 169: objDR =
Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Line 170: While objDR.Read()
Line 171: folder = objDR("folder")
Line 172: End While
Line 173: Conn.Close()
Line 174:
Line 175:
Line 176:
Line 177:
Line 178: #End ExternalSource
Line 179:
__w.Write(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"
"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</body>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</html>")
Line 180:
Line 181:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",40)
Line 182: End If
Line 183:
Line 184: #End ExternalSource
Line 185: End Sub
Line 186:
Line 187: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 188: Protected Overrides Sub FrameworkInitialize()
Line 189: MyBase.FrameworkInitialize
Line 190: Me.__BuildControlTree(Me)
Line 191:
Me.AddWrappedFileDependencies(Global.ASP.bookmarks_aspx.__fileDependencies)
Line 192: Me.Request.ValidateInput
Line 193: End Sub
Line 194:
Line 195: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 196: Public Overrides Function GetTypeHashCode() As Integer
Line 197: Return 1238305174
Line 198: End Function
Line 199:
Line 200: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 201: Public Overrides Sub ProcessRequest(ByVal context As
System.Web.HttpContext)
Line 202: MyBase.ProcessRequest(context)
Line 203: End Sub
Line 204: End Class
Line 205: End Namespace
Line 206:





--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053

Jonathan Wood said:
Although I use C# and may potentually miss some nuances of VB.NET, I don't
see the difference. I suspect that the problem is somewhere other than
the code you posted. Let's see the reference that fails and the exact
error message.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

.nLL said:
hi, im new to asp.net and trying to define a global value. i dont want to
use web.config because i want to be able to run my app on any sub folder
without created an application in iis.

so far i got below in my functons.vb

------------------------
Public Class MyFunctions
Public Shared Function MyDbPath() As String
Return "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|bookmarks.mdb;User Id=admin;Password=;"
End Function


Public Shared Function AlphaNumOnly(ByVal MyString As String) As
String
Dim sResult As String
sResult = Trim(MyString)
If Not sResult = "" Then
sResult = Regex.Replace(MyString,
"[^a-z|A-Z|0-9|\.|\-]{1,50}", "")
End If

Return sResult
End Function
end class
----------------------------------------------

i can use AlphaNumOnly function anywhere within my code and works fine
but when i try to use myfunctions.MyDbPath() i get error saying '
MyDbPath is not member of MYNameSpace.Myfunctions

I can;t see what im doing wrong.

thanks
 
J

Jonathan Wood

Again, I'm not as clear with VB.NET, but it appears you are trying to access
the method as though it were a property. That one that works you are
accessing as a method, which is how both are defined.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

.nLL said:
thanks for reply. here is the ful error
--------------------------------------

Server Error in '/WebApplication1' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'MyDbPath' is not a member of
'MyBookmarks.MyFunctions'.

Source Error:



Line 23: Dim MySql As String
Line 24: MySql = "SELECT folder FROM bookmark Where un='" & MyUn
& "' and not folder='top' GROUP by folder order by folder asc"
Line 25: Dim Conn As New OleDbConnection(MyFunctions.MyDbPath)
Line 26: Dim Cmd As New OleDbCommand(MySql, Conn)
Line 27: Dim objDR As OleDbDataReader


Source File:
C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx
Line: 25



Show Detailed Compiler Output:


C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>
"C:\Windows\Microsoft.NET\Framework\v3.5\vbc.exe" /t:library /utf8output
/R:"C:\Windows\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll"
/R:"C:\Windows\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll"
/R:"C:\Windows\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll"
/R:"C:\Windows\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\assembly\dl3\d1acef42\2bd118b4_6105c901\MyBookmarks.DLL"
/out:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\App_Web_altn4mxt.dll" /D:DEBUG=1
/debug+ /define:_MYTYPE=\"Web\"
/imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Linq,System.Xml.Linq,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls
/warnaserror- /optionInfer+
"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\App_Web_altn4mxt.0.vb"
"C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\webapplication1\b11bdf17\63ad84d8\App_Web_altn4mxt.1.vb"


Microsoft (R) Visual Basic Compiler version 9.0.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.

C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx(25)
: error BC30456: 'MyDbPath' is not a member of 'MyBookmarks.MyFunctions'.

Dim Conn As New OleDbConnection(MyFunctions.MyDbPath)
~~~~~~~~~~~~~~~~~~~~





Show Complete Compilation Source:


Line 1:
#ExternalChecksum("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx","{406ea660-64cf-4c82-b6f0-42d48172a799}","212C28A61811E34E1121B6B0A9ACE78F")
Line 2:
'------------------------------------------------------------------------------
Line 3: ' <auto-generated>
Line 4: ' This code was generated by a tool.
Line 5: ' Runtime Version:2.0.50727.3053
Line 6: '
Line 7: ' Changes to this file may cause incorrect behavior and
will be lost if
Line 8: ' the code is regenerated.
Line 9: ' </auto-generated>
Line 10:
'------------------------------------------------------------------------------
Line 11:
Line 12: Option Strict Off
Line 13: Option Explicit On
Line 14:
Line 15: Imports Microsoft.VisualBasic
Line 16: Imports MyBookmarks
Line 17: Imports System
Line 18: Imports System.Collections
Line 19: Imports System.Collections.Generic
Line 20: Imports System.Collections.Specialized
Line 21: Imports System.Configuration
Line 22: Imports System.Data.OleDb
Line 23: Imports System.Linq
Line 24: Imports System.Text
Line 25: Imports System.Text.RegularExpressions
Line 26: Imports System.Web
Line 27: Imports System.Web.Caching
Line 28: Imports System.Web.Profile
Line 29: Imports System.Web.Security
Line 30: Imports System.Web.SessionState
Line 31: Imports System.Web.UI
Line 32: Imports System.Web.UI.HtmlControls
Line 33: Imports System.Web.UI.WebControls
Line 34: Imports System.Web.UI.WebControls.WebParts
Line 35: Imports System.Xml.Linq
Line 36:
Line 37: Namespace ASP
Line 38:
Line 39: <System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()>
_
Line 40: Public Class bookmarks_aspx
Line 41: Inherits Global.System.Web.UI.Page
Line 42: Implements
System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler
Line 43:
Line 44: Private Shared __initialized As Boolean
Line 45:
Line 46: Private Shared __fileDependencies As Object
Line 47:
Line 48: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 49: Public Sub New()
Line 50: MyBase.New
Line 51: Dim dependencies() As String
Line 52: CType(Me,Global.System.Web.UI.Page).AppRelativeVirtualPath =
"~/bookmarks.aspx"
Line 53: If (Global.ASP.bookmarks_aspx.__initialized =
false) Then
Line 54: dependencies = New String(0) {}
Line 55: dependencies(0) = "~/bookmarks.aspx"
Line 56: Global.ASP.bookmarks_aspx.__fileDependencies =
Me.GetWrappedFileDependencies(dependencies)
Line 57: Global.ASP.bookmarks_aspx.__initialized = true
Line 58: End If
Line 59: Me.Server.ScriptTimeout = 30000000
Line 60: End Sub
Line 61:
Line 62: Protected ReadOnly Property Profile() As
System.Web.Profile.DefaultProfile
Line 63: Get
Line 64: Return
CType(Me.Context.Profile,System.Web.Profile.DefaultProfile)
Line 65: End Get
Line 66: End Property
Line 67:
Line 68: Protected Overrides ReadOnly Property
SupportAutoEvents() As Boolean
Line 69: Get
Line 70: Return false
Line 71: End Get
Line 72: End Property
Line 73:
Line 74: Protected ReadOnly Property ApplicationInstance() As
System.Web.HttpApplication
Line 75: Get
Line 76: Return
CType(Me.Context.ApplicationInstance,System.Web.HttpApplication)
Line 77: End Get
Line 78: End Property
Line 79:
Line 80: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 81: Private Function __BuildControl__control3() As
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 82: Dim __ctrl As
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 83:
Line 84:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",19)
Line 85: __ctrl = New
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 86:
Line 87: #End ExternalSource
Line 88: Return __ctrl
Line 89: End Function
Line 90:
Line 91: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 92: Private Function __BuildControl__control2() As
Global.System.Web.UI.HtmlControls.HtmlHead
Line 93: Dim __ctrl As
Global.System.Web.UI.HtmlControls.HtmlHead
Line 94:
Line 95:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",18)
Line 96: __ctrl = New
Global.System.Web.UI.HtmlControls.HtmlHead("head")
Line 97:
Line 98: #End ExternalSource
Line 99: Dim __ctrl1 As
Global.System.Web.UI.HtmlControls.HtmlTitle
Line 100:
Line 101:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",18)
Line 102: __ctrl1 = Me.__BuildControl__control3
Line 103:
Line 104: #End ExternalSource
Line 105: Dim __parser As System.Web.UI.IParserAccessor =
CType(__ctrl,System.Web.UI.IParserAccessor)
Line 106:
Line 107:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",18)
Line 108: __parser.AddParsedSubObject(__ctrl1)
Line 109:
Line 110: #End ExternalSource
Line 111: Return __ctrl
Line 112: End Function
Line 113:
Line 114: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 115: Private Sub __BuildControlTree(ByVal __ctrl As
bookmarks_aspx)
Line 116:
Line 117:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",1)
Line 118: Me.InitializeCulture
Line 119:
Line 120: #End ExternalSource
Line 121: Dim __ctrl1 As
Global.System.Web.UI.HtmlControls.HtmlHead
Line 122:
Line 123:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",1)
Line 124: __ctrl1 = Me.__BuildControl__control2
Line 125:
Line 126: #End ExternalSource
Line 127: Dim __parser As System.Web.UI.IParserAccessor =
CType(__ctrl,System.Web.UI.IParserAccessor)
Line 128:
Line 129:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",1)
Line 130: __parser.AddParsedSubObject(__ctrl1)
Line 131:
Line 132: #End ExternalSource
Line 133: __ctrl.SetRenderMethodDelegate(AddressOf
Me.__Render__control1)
Line 134: End Sub
Line 135:
Line 136: Private Sub __Render__control1(ByVal __w As
System.Web.UI.HtmlTextWriter, ByVal parameterContainer As
System.Web.UI.Control)
Line 137:
Line 138:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",5)
Line 139:
Line 140: 'check if user
exist-------------------------------------------------------
Line 141:
'--------------------------------------------------------------------------
Line 142: Dim MyUn As String =
MyFunctions.AlphaNumOnly(Request.QueryString("un"))
Line 143: Dim MyPw As String =
MyFunctions.AlphaNumOnly(Request.QueryString("pw"))
Line 144:
Line 145: If MyFunctions.CheckLogin(MyUn, MyPw) = 0 Then
Line 146: Response.Write("http://google.com")
Line 147: Else
Line 148:
'--------------------------------------------------------------------------
Line 149:
'--------------------------------------------------------------------------
Line 150:
Line 151:
Line 152: #End ExternalSource
Line 153: __w.Write("<!DOCTYPE html PUBLIC ""-//W3C//DTD
XHTML 1.0 Transitional//EN"" ""http://www.w3.org"& _
Line 154:
"/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<html
xmlns=""http://www.w3.org/1999/xh"& _
Line 155: "tml""
"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
Line 156: parameterContainer.Controls(0).RenderControl(__w)
Line 157:
__w.Write(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<body>")
Line 158:
Line 159:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",21)
Line 160:
Line 161:
Line 162: Dim MySql As String
Line 163: MySql = "SELECT folder FROM bookmark Where un='" &
MyUn & "' and not folder='top' GROUP by folder order by folder asc"
Line 164: Dim Conn As New OleDbConnection(MyFunctions.MyDbPath)
Line 165: Dim Cmd As New OleDbCommand(MySql, Conn)
Line 166: Dim objDR As OleDbDataReader
Line 167: Dim folder As String
Line 168: Conn.Open()
Line 169: objDR =
Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Line 170: While objDR.Read()
Line 171: folder = objDR("folder")
Line 172: End While
Line 173: Conn.Close()
Line 174:
Line 175:
Line 176:
Line 177:
Line 178: #End ExternalSource
Line 179:
__w.Write(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"
"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</body>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</html>")
Line 180:
Line 181:
#ExternalSource("C:\Users\Administrator\Desktop\WebApplication1\WebApplication1\bookmarks.aspx",40)
Line 182: End If
Line 183:
Line 184: #End ExternalSource
Line 185: End Sub
Line 186:
Line 187: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 188: Protected Overrides Sub FrameworkInitialize()
Line 189: MyBase.FrameworkInitialize
Line 190: Me.__BuildControlTree(Me)
Line 191:
Me.AddWrappedFileDependencies(Global.ASP.bookmarks_aspx.__fileDependencies)
Line 192: Me.Request.ValidateInput
Line 193: End Sub
Line 194:
Line 195: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 196: Public Overrides Function GetTypeHashCode() As Integer
Line 197: Return 1238305174
Line 198: End Function
Line 199:
Line 200: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Line 201: Public Overrides Sub ProcessRequest(ByVal context As
System.Web.HttpContext)
Line 202: MyBase.ProcessRequest(context)
Line 203: End Sub
Line 204: End Class
Line 205: End Namespace
Line 206:





--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053

Jonathan Wood said:
Although I use C# and may potentually miss some nuances of VB.NET, I
don't see the difference. I suspect that the problem is somewhere other
than the code you posted. Let's see the reference that fails and the
exact error message.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

.nLL said:
hi, im new to asp.net and trying to define a global value. i dont want
to use web.config because i want to be able to run my app on any sub
folder without created an application in iis.

so far i got below in my functons.vb

------------------------
Public Class MyFunctions
Public Shared Function MyDbPath() As String
Return "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|bookmarks.mdb;User Id=admin;Password=;"
End Function


Public Shared Function AlphaNumOnly(ByVal MyString As String) As
String
Dim sResult As String
sResult = Trim(MyString)
If Not sResult = "" Then
sResult = Regex.Replace(MyString,
"[^a-z|A-Z|0-9|\.|\-]{1,50}", "")
End If

Return sResult
End Function
end class
----------------------------------------------

i can use AlphaNumOnly function anywhere within my code and works fine
but when i try to use myfunctions.MyDbPath() i get error saying '
MyDbPath is not member of MYNameSpace.Myfunctions

I can;t see what im doing wrong.

thanks
 
C

Cowboy \(Gregory A. Beamer\)

Namespace problem based on the way VB works with folders, at least that is
my first guess as to why you are having issues.

Now, the best way to find your problem this is download Reflector (now a
RedGate tool, but still free):
http://www.red-gate.com/products/reflector/

Compile your website (or run a page). Look in the /bin folder using
reflector. The actual file name for the DLL is folderName.dll, at least in
general. Open it up and notice declarations for namespaces. You will have to
delete the directive in the page to get this to compile and see this in
action, but you will see what is going on.

Choices
1. Turn off default VB behavior in options
2. Add Imports statements to your page
3. Explicitly add a namespace to your VB functions class file
 
N

.nLL

my solution was


Public Shared ReadOnly Property MyDbPath() As String
Get
Return "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|bookmarks.mdb;User Id=admin;Password=;"
End Get
End Property



thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top