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

FbDataAdapter.FbCommand.Parameters.AddRange() Method Infinite Loop [DNET138] #149

Closed
firebird-automations opened this issue Nov 20, 2007 · 4 comments

Comments

@firebird-automations
Copy link

Submitted by: Brian Liedtke (liedtke)

Attempting to add an array of FbParameters to a FbDataAdapter.Command using the AddRange() method. This caused
a StackOverflow. Modified to use the Add() method iterating through each array element and it works fine.

Code that broke
private FbDataAdapter hda = null;

    private FbParameter\[\] Params = 
    \{
        new FbParameter\("@person\_id", FbDbType\.Integer, sizeof\(int\), "person\_id"\),
        new FbParameter\("@first\_name", FbDbType\.VarChar, Defaults\.Person\.FirstNameLen, "first\_name"\),
        new FbParameter\("@last\_name", FbDbType\.VarChar, Defaults\.Person\.LastNameLen, "last\_name"\),
        new FbParameter\("@nick\_name", FbDbType\.VarChar, Defaults\.Person\.NickNameLen, "nick\_name"\),
        new FbParameter\("@name\_prefix", FbDbType\.VarChar, Defaults\.Person\.NamePrefixLen, "name\_prefix"\),
        new FbParameter\("@name\_suffix", FbDbType\.VarChar, Defaults\.Person\.NameSuffixLen, "name\_suffix"\),
        new FbParameter\("@chgdate", FbDbType\.Date, sizeof\(int\), "chgdate"\)
    \};

    public FamilyData\(Database DB\)
    \{
        this\.hda = new FbDataAdapter\(HusbandSelectSql, DB\.Conn\);
        this\.hda\.SelectCommand\.Parameters\.Add\("@family\_id", FbDbType\.Integer\);
        this\.hda\.InsertCommand = new FbCommand\(InsertPersonSql, DB\.Conn\);
        this\.hda\.InsertCommand\.Parameters\.AddRange\(Params\);
        \.\.\.\.\.\.\.\.\.\.\.
    \}

The AddRange() causes a stack overfloe.
Substituted the AddRange() call on the last line to

        for \(int i = 0; i < Params\.Length; i\+\+\)
            this\.hda\.InsertCommand\.Parameters\.Add\(Params\[i\]\);

and it runs correctly.

So, I believe there is a problem in the AddRange() method.
Not using FbCommandBuilder to generate the Insert, Delete, Update commands because
HusbandSelectSql is a multitable select.

If you want me to look at it I will, but I am on a deadline with this project and it will be awhile before I can
get to it.

Commits: 0b81674

@firebird-automations
Copy link
Author

Modified by: @cincuranet

assignee: Carlos Guzman Alvarez [ carlosga_fb ] => Jiri Cincura [ cincura_net ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

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

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Fixed.
rev.427 (2.5, trunk)
rev.428 (2.1, branch)

@firebird-automations
Copy link
Author

Modified by: @cincuranet

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

resolution: Fixed [ 1 ]

Fix Version: 2.1.0 [ 10102 ]

Fix Version: 2.5.0 [ 10170 ]

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