D
dave
I am having trouble accessing a property set during run-time in a user
control that I have built. The control is supposed to connect to a
database using the path supplied by the developer at runtime. Any
assistance would be greatly appreciated. The code is as follows:
In the class I declared the private variable strDatabasePath
public partial class UserControl1 : UserControl
{ //... other code
private string strDatabasePath;
//... other code
}
I created the DatabasePath accessor to store the user input from
design-time into the variable. The property shows up in the User
Control's property window.
[Browsable(true), Category("Database"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
DefaultValue(true),
Description("Sets and gets the database path.")]
public string DatabasePath
{
get
{
return strDatabasePath;
}
set
{
strDatabasePath = value;
}
}
In the load method I attempt to use the strDatabasePath variable to
access database.The variable is always set to null when I check it in
the debugger whether I set it in the property window during design time
or not.
private void UserControl1_Load(object sender, EventArgs e)
{
//... other code
//Establish Connection to the Database
MyDbConnect = new DataConnect(strDatabasePath);
//... other code
}
control that I have built. The control is supposed to connect to a
database using the path supplied by the developer at runtime. Any
assistance would be greatly appreciated. The code is as follows:
In the class I declared the private variable strDatabasePath
public partial class UserControl1 : UserControl
{ //... other code
private string strDatabasePath;
//... other code
}
I created the DatabasePath accessor to store the user input from
design-time into the variable. The property shows up in the User
Control's property window.
[Browsable(true), Category("Database"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
DefaultValue(true),
Description("Sets and gets the database path.")]
public string DatabasePath
{
get
{
return strDatabasePath;
}
set
{
strDatabasePath = value;
}
}
In the load method I attempt to use the strDatabasePath variable to
access database.The variable is always set to null when I check it in
the debugger whether I set it in the property window during design time
or not.
private void UserControl1_Load(object sender, EventArgs e)
{
//... other code
//Establish Connection to the Database
MyDbConnect = new DataConnect(strDatabasePath);
//... other code
}