overloaded constructors

E

esebastian

hello all,
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.Default.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???
Thanks,
Erin
 
D

Dustin Campbell

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top