PC Review


Reply
Thread Tools Rate Thread

Component problem, pls help!

 
 
CM
Guest
Posts: n/a
 
      7th Oct 2003
Hi there:
I created an ASP.Net project. I added and implemented a component
DataAcess.vb and there are several methods such as

Namespace ABC.Components
Public Class DBAccess
Public Function MakeInParam(...) As SqlParameter

...

End Function

Public Sub Open()


...

End Sub

End Class

End Namespace

In another component (Login.vb) in the same namespace, I have included the
namespace ABC.Components, and the "New" key word is followed with a dropdown
list that contains the class name 'DBAccess', But non of these methods such
as DBAccess.MakeInParam is shown in the other component such as Login.vb

Dim data As New DBAccess 'this line is okay

'this line causes a syntax error: type DBAccess.makeinparam is not defined:

Dim data As New DBAccess.makeinparam



What's wrong? How to fix this problem?

Thanks!

CM


 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      7th Oct 2003
"CM" <(E-Mail Removed)> schrieb
> Hi there:
> I created an ASP.Net project. I added and implemented a component
> DataAcess.vb and there are several methods such as
>
> Namespace ABC.Components
> Public Class DBAccess
> Public Function MakeInParam(...) As SqlParameter
>
> ...
>
> End Function
>
> Public Sub Open()
>
>
> ...
>
> End Sub
>
> End Class
>
> End Namespace
>
> In another component (Login.vb) in the same namespace, I have
> included the namespace ABC.Components, and the "New" key word is
> followed with a dropdown list that contains the class name
> 'DBAccess', But non of these methods such as DBAccess.MakeInParam is
> shown in the other component such as Login.vb
>
> Dim data As New DBAccess 'this line is okay
>
> 'this line causes a syntax error: type DBAccess.makeinparam is not
> defined:
>
> Dim data As New DBAccess.makeinparam
>
>
>
> What's wrong? How to fix this problem?



The new keyword creates a new object. After "New", you write the type name.
DBAccess.makeinparam is not a type, it is a member of a type. You can create
instances of the DBAccess class and use the members of the created object.
See the OOP (object oriented programming) sections in the VB.NET docs.


--
Armin

 
Reply With Quote
 
Tom Spink
Guest
Posts: n/a
 
      7th Oct 2003
Hi CM,

What are you trying to do?

MakeInParam is a method, not a class, so you cannot create an instance of
it... Are you trying to call that method?

If so, all you need is:

data.MakeInParam(...)

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations


"CM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi there:
> I created an ASP.Net project. I added and implemented a component
> DataAcess.vb and there are several methods such as
>
> Namespace ABC.Components
> Public Class DBAccess
> Public Function MakeInParam(...) As SqlParameter
>
> ...
>
> End Function
>
> Public Sub Open()
>
>
> ...
>
> End Sub
>
> End Class
>
> End Namespace
>
> In another component (Login.vb) in the same namespace, I have included the
> namespace ABC.Components, and the "New" key word is followed with a

dropdown
> list that contains the class name 'DBAccess', But non of these methods

such
> as DBAccess.MakeInParam is shown in the other component such as Login.vb
>
> Dim data As New DBAccess 'this line is okay
>
> 'this line causes a syntax error: type DBAccess.makeinparam is not

defined:
>
> Dim data As New DBAccess.makeinparam
>
>
>
> What's wrong? How to fix this problem?
>
> Thanks!
>
> CM
>
>



 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      7th Oct 2003
Hi CM,

Dim data As New DBAccess 'this line is okay

This line <is> ok because 'As' must be followed by a Type and DBAccess
<is> a Type.

Dim data As New DBAccess.makeinparam

But this line will cause a problem because DBAccess.makeinparam is <not> a
Type - it's a method of an instance of a Type.

However,
Dim data As New DBAccess
Dim SquealyPram As SqlParameter
SquealyPram = data.makeinparam (...)
will work, because data is an object, and makeinparam is an object
method.and they like each other just fine.

Regards,
Fergus


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      7th Oct 2003
"CM" <(E-Mail Removed)> scripsit:
> I created an ASP.Net project. I added and implemented a component
> DataAcess.vb and there are several methods such as
>
> Namespace ABC.Components
> Public Class DBAccess
> Public Function MakeInParam(...) As SqlParameter
>
> ...
>
> End Function
>
> Public Sub Open()
>
>
> ...
>
> End Sub
>
> End Class
>
> End Namespace
>
> In another component (Login.vb) in the same namespace, I have included the
> namespace ABC.Components, and the "New" key word is followed with a dropdown
> list that contains the class name 'DBAccess', But non of these methods such
> as DBAccess.MakeInParam is shown in the other component such as Login.vb
>
> Dim data As New DBAccess 'this line is okay
>
> 'this line causes a syntax error: type DBAccess.makeinparam is not defined:
>
> Dim data As New DBAccess.makeinparam


'MakeInParam' is a method, not a type. You can _call_ the method, but
you cannot instantiate it.

\\\
Dim c As New DBAccess()
Dim p As ... = c.MakeInParam(...)
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
CM
Guest
Posts: n/a
 
      7th Oct 2003
Thanks for reply.
I think you are all right but this line still not working:

Dim p As ... = c.MakeInParam(...)

Even I type
DBAccess. 'I expect the "open" method will popup in the list, but no.

Nothing follows the dot.

CM


"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:blvbee$grop3$(E-Mail Removed)...
> "CM" <(E-Mail Removed)> scripsit:
> > I created an ASP.Net project. I added and implemented a component
> > DataAcess.vb and there are several methods such as
> >
> > Namespace ABC.Components
> > Public Class DBAccess
> > Public Function MakeInParam(...) As SqlParameter
> >
> > ...
> >
> > End Function
> >
> > Public Sub Open()
> >
> >
> > ...
> >
> > End Sub
> >
> > End Class
> >
> > End Namespace
> >
> > In another component (Login.vb) in the same namespace, I have included

the
> > namespace ABC.Components, and the "New" key word is followed with a

dropdown
> > list that contains the class name 'DBAccess', But non of these methods

such
> > as DBAccess.MakeInParam is shown in the other component such as Login.vb
> >
> > Dim data As New DBAccess 'this line is okay
> >
> > 'this line causes a syntax error: type DBAccess.makeinparam is not

defined:
> >
> > Dim data As New DBAccess.makeinparam

>
> 'MakeInParam' is a method, not a type. You can _call_ the method, but
> you cannot instantiate it.
>
> \\\
> Dim c As New DBAccess()
> Dim p As ... = c.MakeInParam(...)
> ///
>
> --
> Herfried K. Wagner
> MVP · VB Classic, VB.NET
> <http://www.mvps.org/dotnet>



 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      7th Oct 2003
"CM" <(E-Mail Removed)> schrieb
> Thanks for reply.
> I think you are all right but this line still not working:
>
> Dim p As ... = c.MakeInParam(...)


p As what? What's the declaration of "c"?

> Even I type
> DBAccess.


Where do you type DBAccess?

> 'I expect the "open" method will popup in the list, but
> no.
>
> Nothing follows the dot.




--
Armin

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Oct 2003
"CM" <(E-Mail Removed)> scripsit:
> I think you are all right but this line still not working:
>
> Dim p As ... = c.MakeInParam(...)
>
> Even I type
> DBAccess. 'I expect the "open" method will popup in the list, but no.
>
> Nothing follows the dot.


Please post more code. Which error/exception do you get?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
CM
Guest
Posts: n/a
 
      8th Oct 2003
Thanks for all everyone's help!

I've checked some error message:

Dim Data1 as new DBAccess 'this line is fine.

This line causes an error( I'll handle it later) : [the value of
'data.MakeInParam("@userID", SqlDbType.Char, 80, userID)' cannot be
converted to one demensional array of
ystem.data.sqlClient.SqlParameter() ]:
SqlParameter() = data.MakeInParam("@userID", SqlDbType.Char, 80, userID)

But for this line (begin at new line) there is nothing following the dot:

DBAccess. 'nothing following the dot

If I put this line:
DBAccess.MakeInParam() 'An error: Reference to a non-shard member requires
an object references.

It is seemed the problem is "non-shard", but sorry, I don't know what this
mean.
Please continue your help!

Thanks!

CM


"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:blvhdn$gtfrm$(E-Mail Removed)...
> "CM" <(E-Mail Removed)> scripsit:
> > I think you are all right but this line still not working:
> >
> > Dim p As ... = c.MakeInParam(...)
> >
> > Even I type
> > DBAccess. 'I expect the "open" method will popup in the list, but no.
> >
> > Nothing follows the dot.

>
> Please post more code. Which error/exception do you get?
>
> --
> Herfried K. Wagner
> MVP · VB Classic, VB.NET
> <http://www.mvps.org/dotnet>



 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      8th Oct 2003
Hi CM,

SqlParameter() = data.MakeInParam (....)

It's confusing because () can be used with a method which takes no
arguments and with variables that are arrays. In this case the compiler thinks
that SqlParameter() is an array. As MakeInParam only returns a single
SqlParameter you don't need (). But you do need to have defined a variable.

Dim SqlParam As SqlParameter
SqlParam = data.MakeInParam (....)

Have another read of the replies that we've given you. I've already shown
you something very similar to this example.

===========================

DBAccess.

What are you expecting to appear ?? What do you want to do with DBAccess
at this point?

Regards,
Fergus


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using my own component pRumpf@procom-gmbh.com Microsoft Dot NET 0 13th Feb 2006 10:11 AM
Problem with my component Mauro Microsoft C# .NET 3 16th Sep 2004 11:17 AM
Component problem nht Microsoft C# .NET 0 9th Aug 2004 05:59 AM
Problem with FSO component Michael S. Androsov Microsoft Windows 2000 0 21st May 2004 07:17 AM
add component problem hslan Windows XP Embedded 1 28th Jan 2004 12:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:23 PM.