Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FbConnectionStringBuilder default values behavior [DNET281] #293

Closed
firebird-automations opened this issue Nov 4, 2009 · 10 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: Vasily Kabanov (vaso)

Attachments:
FbConnectionString.cs
FbConnectionStringBuilder.cs
dBDefaultValues.pdf
FbConnectionStringBuilder.cs
dBDefaultValues.pdf

Votes: 3

1) None of the properties in the connection string builder appears to have default values: if you create new instance with parameterless constructor and try to get any property value you get an ArgumentException because all the properties directly query the base class for hard-coded key value. This is very different from other builders (such as SqlConnectionStringBuilder) and causes problems such as when you try to create database connection dialog for the user. All these defaults need to be implemented manually anyway in a wrapper.

fb.FbConnectionStringBuilder fbld = new fb.FbConnectionStringBuilder();
string userID = fbld.UserID; // throws exception

System.Data.SqlClient.SqlConnectionStringBuilder bld = new System.Data.SqlClient.SqlConnectionStringBuilder();
userID = bld.UserID; // returns empty string

2) If you set a property and then want to revert to default (delete key-value pair) there's no graceful way (for example, for integer properties) as key names are hard-coded as literals and not exposed (as public constants, for example). Also, after creating empty conn.string builder its Keys collection is empty which is again different from other implementations.

Commits: 2045647

@firebird-automations
Copy link
Author

Commented by: Luigi Piccinni (luigi.piccinni)

I tried to analyze this minor bug reported and solve it.

I made the following changes (relate to the .cs files in attachment):

Class FbConnectionString.cs (line 105 to 125) - Added some static readonly fields as default values for the connection strings

Class FbConnectionString.cs, private method SetDefaultOptions() (line 396 to 416) - Modified the value of the pairs with the new declared default fields

Class FbConnectionStringBuilder.cs, constructor FbConnectionStringBuilder() (line 166) - Line added that point to the new private method SetDefaultValues()

Class FbConnectionStringBuilder.cs, private method SetDefaultValues() (line 241 to 264) - new method added

Effect:
The default constructor of FbConnectionStringBuilder puts the default values in all Properties so that it doesn't cause an exception to get a Property before assigning its value manually.
The same default values are assigned to the FbConnectionString replacing the hard-coded ones.
Moreover one can go back to the default value simply calling the fields FbConnectionString.DEFAULT_*

This should cover both the point 1 and 2 of the bug reported.

@firebird-automations
Copy link
Author

Modified by: Luigi Piccinni (luigi.piccinni)

Attachment: FbConnectionString.cs [ 11580 ]

Attachment: FbConnectionStringBuilder.cs [ 11581 ]

@firebird-automations
Copy link
Author

Commented by: Jitka Dařbujanová (jitka)

Any progress here Mr.Jiří?
Is there fix version planned for the future?
Thanks much

Jitka Dařbujanová
(from the town below the rotary hyperboloid ;))

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Hi Jitka, no progress so far nor plans.

@firebird-automations
Copy link
Author

Commented by: Leonard Wennekers (l.wennekers)

Hello
I'm trying to use the Firebird .Net DataProvider as others and I've seen the same problems as mentioned above. I added a document with some screenshots that I made while adding existing databases to my Visual Studio project by using the template http://ADO.NET Entity Data Model. It seams that other dataproviders are showing there defaults and all changed properties well by using the advanced button. Therefor I've been looking for a solution to improve the FbConnectionStringBuilder of the Firebird .Net DataProvider because we are going to use Firebird as other database for our project. This improvement also improved the visibility of defaults inside the windows after the advanced button is pressed. A screenshot of this window is also added to the PDF document.

I also added a new file FbConnectionStringBuilder.cs which does now what I expected and I hope that this new file will also be helpfull for many others and can be used in the next version of the Firebird .Net Dataprovider.

Thanks in advance for looking to the new code.
Best regards
Leonard Wennekers

@firebird-automations
Copy link
Author

Modified by: Leonard Wennekers (l.wennekers)

Attachment: dBDefaultValues.pdf [ 11900 ]

Attachment: FbConnectionStringBuilder.cs [ 11901 ]

@firebird-automations
Copy link
Author

Commented by: Leonard Wennekers (l.wennekers)

Sorry I had the wrong PDF attatched.
Hereby the corrected version
L. Wennekers

@firebird-automations
Copy link
Author

Modified by: Leonard Wennekers (l.wennekers)

Attachment: dBDefaultValues.pdf [ 11902 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: vNext [ 10744 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants