Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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
 
Old June 17th, 2004, 03:46 PM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Import NameSpace in VB?


Hi all,

I have a problem in Importing Namespace.
To be clear, I have two .vb files and I want to use
some functions which exist within the first .vb file in the second one.

Example:
In the first "x.vb" file I have functions X and Y.
I have a NameSpace called YYYYY in x.vb. i.e,

Imports System
.....
NameSpace YYYYY
public class MMM
.......
 function X()
 ......
 function Y()
.......

If I want to use functions X() and Y() from the above x.vb file
in my second file called z.vb, so how can I import functions X() and Y().

I tried to compile my second vb file by using " Import YYYYY", but I got YYYYY is not defined error.
Could you guys give me hint?
Thanks



 
Old June 17th, 2004, 03:57 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The answer is right in front of you.

Imports System

Imports YYYYY
 
Old June 17th, 2004, 04:25 PM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I have tried to import YYYYY, and YYYYY.MMM
It does not work

 
Old June 17th, 2004, 04:48 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Import[u]s</u> YYYYY

Just like

Import[u]s</u> System
 
Old June 17th, 2004, 05:03 PM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again,
I have tried many times, checked spelling and I only get
BC30466: Namespace or type 'YYYYY' not defined.
I am not good in .NET. Do u think that it has something to do
with web.config file.



 
Old June 18th, 2004, 07:52 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok, let's back up a minute.
Can you describe your development scenario?
What are you developing in?
Are you compiling this code?
If you are developing in visual studio, are the two .vb files in the same project?
 
Old June 18th, 2004, 09:15 AM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again,

I tried to import it from .asmx file, it worked without complaining.
I think it is ok now, I tried to write a code that authenticate
users of a small web service through SOAP header. It seems it is working now.
I have a few question that I would like to ask you.
Do you know any good articles/books in .NET web service security, with examples?
Is there any password mask technology in VB?
You can look at the code written below (it is an .asmx file - web service), when I run it and enter the value for password parameter the whole text of password appears, how Could I make the password hidden in this case? I do not want to use soap header here.

<%@ WebService Language="vb" Class="ISBN" %>
Imports System.Web.Services
Imports System.Data
Imports System.Data.OleDb


Public Class ISBN
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function BookDetail(ByVal strIsbn As String) As String
      ByVal strUsername As String, _
      ByVal strPassword As String) As String
    Dim SecurityDr As OleDbDataReader
    Dim SecurityConn As OleDbConnection
    Dim SecurityCmd As OleDbCommand

    Dim Conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
        Conn += Server.MapPath("Security.mdb") & ";"
    Dim SQL As String = "select Username from Users where username = '"
        SQL += strUsername & "' and password = '" & strPassword & "'"

    SecurityConn = New OleDbConnection(Conn)
    SecurityCmd = New OleDbCommand(SQL, SecurityConn)
    SecurityConn.Open()

    SecurityDr = _
      SecurityCmd.ExecuteReader(CommandBehavior.CloseCon nection)
    If SecurityDr.Read() Then
      SecurityDr.Close()
      Return GetBookDetails(Isbn)
    Else
      SecurityDr.Close()
      Return "Login to library failed."
    End If
    End Function

    Private Function GetBookDetails(ByVal strIsbn As String) As String
        Dim objLibraryDR As OleDbDataReader
        Dim objLibraryConn As OleDbConnection
        Dim objLibraryCmd As OleDbCommand
        Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Library.mdb") & ";"
        Dim strSQL As String = "select Title from Books where ISBN = '" & strIsbn & "'"
        Dim strBookTitle As String

        objLibraryConn = New OleDbConnection(strConn)
        objLibraryCmd = New OleDbCommand(strSQL, objLibraryConn)
        objLibraryConn.Open()

        objLibraryDR = objLibraryCmd.ExecuteReader(CommandBehavior.CloseC onnection)
        If objLibraryDR.Read() Then
            strBookTitle = objLibraryDR(0)
        Else
            strBookTitle = "Book not found in the database"
        End If
        objLibraryDR.Close()

        Return strBookTitle
    End Function

End Class










Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax error? <%@ Import Namespace="System.Data" % fjm9 C# 1 January 16th, 2007 09:17 AM
Import Namespace seannie ASP.NET 2.0 Basics 0 December 7th, 2006 04:48 AM
Can't import a namespace w/vbc command line oneillj ASP.NET 1.0 and 1.1 Basics 0 June 14th, 2006 08:05 PM
Error import namespace sersanoi Classic ASP Databases 0 August 18th, 2005 12:10 PM





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