Answered by:
Difference between class and class()

Question
-
User-1625965328 posted
hi there,
while reading a book i encountered the use of a statement in asp.net(with vb as code language)
dim myReader as OracleDataReader(declared as global variable)[Correct]
however by mistake i used code as shown below
dim myReader as OracleDataReader()[Produced error]
error found at compile time when i tried 2 execute this :
myReader = myCommand.ExecuteReader()
Error 1 Value of type 'Oracle.DataAccess.Client.OracleDataReader' cannot be converted to '1-dimensional array of Oracle.DataAccess.Client.OracleDataReader'. F:\Documents and Settings\dellid\My Documents\Visual Studio 2010\WebSites\WebSite2\Inline_DataReader.aspx.vb 15 24 F:\...\WebSite2\
it's workin correct when using OracleDataReader without brackets(as earlier in book)
I just want to know the difference between oracleDatarReader and OracleDataReader()
Any other similar example will be also helpfull
Regards
CrZyLink
Saturday, December 18, 2010 6:19 AM
Answers
-
User-1618234021 posted
Hi
When you are saying:
dim myReader as OracleDataReader [Refrence Delcaration]
This means you are creating a refrence of type OracleDataReader which will point to records coming from oracle when a select command is executed.
But when you say
dim myReader as OracleDataReader() [Array Declaration]
This means you are trying to create an empty array object which will point to an array of OracleDataReader refrences. Which in this case is not correct. You will always create a refrence and then point it to comm.ExecuteReader()
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 18, 2010 7:28 AM
All replies
-
User-1618234021 posted
Hi
When you are saying:
dim myReader as OracleDataReader [Refrence Delcaration]
This means you are creating a refrence of type OracleDataReader which will point to records coming from oracle when a select command is executed.
But when you say
dim myReader as OracleDataReader() [Array Declaration]
This means you are trying to create an empty array object which will point to an array of OracleDataReader refrences. Which in this case is not correct. You will always create a refrence and then point it to comm.ExecuteReader()
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 18, 2010 7:28 AM -
User-924503612 posted
well im not sure what OracleDataReader class do but if u want explanation i can say:
sqldatareader sdr = new sqldatareader();
this means i declare an object of class sqldatareader();
both left and right side shows class name; i.e. sqldatareader but on the right hand side its a class name or u rather call it constructer which is some sort of initializer of the class. it may require some parameter to give/ initialize special type of object.
hope this clears ur query
(im used to of C# cannt quote vb examples :)Saturday, December 18, 2010 8:40 AM -
User-1625965328 posted
thanx a lot for ur prompt reply!! but i felt that doesn't explains the difference between sqldatareader and sqldatareader()
nywayz another answer sorted out my confusion.
but thanx again!!
CrZyLink!!
Sunday, December 19, 2010 3:16 AM -
Sunday, December 19, 2010 3:18 AM