B
Brad Pears
(keep in mind I am very new to OO design and development etc...)
I have an SQL Server 2000 db table that holds system values. There is only
ONE row in this table. I have created a class specifically for this table.
When a user instantiates the "System_Data" object, I would like that
object's properties to be populated with the values from the SQL Server
"System" table. So, when writing the following code elsewhere in my
project...
dim oSys as new System_Data
msgbox ("Contract Number: " & osys.NextContractNo & " has been created.")
the msgbox should return the next contract number that was stored in the SQL
table.
In order to do this, in the "Sub New" for my System_Data class, I call a
stored procedure that returns all of the fields in that table as output
variables. My next question is this.... Once I have run the stored
procedure, the very next thing I want to do is to assign the values to the
specific properties of my class from the output parameters returned by my
stored procedure. How do I actually assign the values to the properties
without doing something like...
dim osys as New SystemData
osys.NextContractNo =
Convert.ToInt32(objCommand.Partameters("@iNextContractNo"))
Becasue, if I try the above code, as soon as the dim statement is hit, my
"sub new" will run AGAIN and I will be in an infinite loop...
Can someone maybe explain a better way to do this type of thing OR maybe THE
way to do this type of thing?? Maybe I should NEVER be assigning values to a
newly instantiated object at all in the "sub new" procedure for a class?
Help!
Thanks, Brad
I have an SQL Server 2000 db table that holds system values. There is only
ONE row in this table. I have created a class specifically for this table.
When a user instantiates the "System_Data" object, I would like that
object's properties to be populated with the values from the SQL Server
"System" table. So, when writing the following code elsewhere in my
project...
dim oSys as new System_Data
msgbox ("Contract Number: " & osys.NextContractNo & " has been created.")
the msgbox should return the next contract number that was stored in the SQL
table.
In order to do this, in the "Sub New" for my System_Data class, I call a
stored procedure that returns all of the fields in that table as output
variables. My next question is this.... Once I have run the stored
procedure, the very next thing I want to do is to assign the values to the
specific properties of my class from the output parameters returned by my
stored procedure. How do I actually assign the values to the properties
without doing something like...
dim osys as New SystemData
osys.NextContractNo =
Convert.ToInt32(objCommand.Partameters("@iNextContractNo"))
Becasue, if I try the above code, as soon as the dim statement is hit, my
"sub new" will run AGAIN and I will be in an infinite loop...
Can someone maybe explain a better way to do this type of thing OR maybe THE
way to do this type of thing?? Maybe I should NEVER be assigning values to a
newly instantiated object at all in the "sub new" procedure for a class?
Help!
Thanks, Brad