Re: overloaded constructors

Tech-Archive recommends: Fix windows errors by optimizing your registry



This is probably fairly simple but i can't get it to work. I have a
database wrapper that i created to encapsulate the ado functionality.
I have 1 constructor that does not take any parameters and now i want to
create another constructor that takes an SqlTransaction as a parameter
and then i want it to call the first constructor to do the work that
needs to be done. How do i do this....
this is what i have so far

public ADODatabaseWrapper()
{
// get the connection string from the application settings
connectionString =
eSolutions.AssetManagement.ORMMappingProject.Properties.Settings.Defau
lt.DatabaseConnectionString;
}
public ADODatabaseWrapper(SqlTransaction transaction)
{
if(transaction != null)
{
this.transaction = transaction;
}
}

I think i have to do something like :this( pass in value) but how do i
pass my value in???

It sounds to me like you want to do this:

public ADODatabaseWrapper()
{
// get the connection string from the application settings
connectionString = eSolutions.AssetManagement.ORMMappingProject.Properties.Settings.Default.DatabaseConnectionString;
}

public ADODatabaseWrapper(SqlTransaction transaction): this()
{
if(transaction != null)
{
this.transaction = transaction;
}
}


Best Regards,
Dustin Campbell
Developer Express Inc.


.



Relevant Pages

  • overloaded constructors
    ... database wrapper that i created to encapsulate the ado functionality. ... have 1 constructor that does not take any parameters and now i want to ... // get the connection string from the application settings ... public ADODatabaseWrapper(SqlTransaction transaction) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: using super
    ... I am trying to declare a constructor that accepts the ... > same parameters as the Transaction constructor and pass them to the ... > I think this should work, but I'm rather new to 'super' ... > Transaction(double amount, Date transDate){ ...
    (comp.lang.java.help)
  • Re: using super
    ... > constructor and pass them to the Transaction constructor. ... Somewhere here you must have defined 'Date transDate', ... Logically I would guess that you also have a 'double amount' in there ...
    (comp.lang.java.help)
  • TransactionScope Transactions not commiting
    ... be) using the same SQL Connection. ... and dtermines the Connection String to use to create the connection to ... MyClass obj = new MyClass; ... not involved in a Transaction. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Problem with Connection based Transaction in SQL Helper class
    ... Since the "Persist Security Info" is false by default, the connection string obtained from SqlTransaction object hides the pwd part. ... ExecuteScalar(ByVal transaction As SqlTransaction, _ ...
    (microsoft.public.dotnet.languages.csharp)