#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    2
    Rep Power
    0

    Strange problem on FbDataAdapter.Fill after calling a stored procedure (net provider)


    Hello everybody,

    I'm fairly new to the world of firebird and asp.net. On www.dotnetjunkies.com I found an article on calling (testing) stored procedures from an asp.net application. I thought it nice exercise to try to adapt the code given there, to use firebird and the .net provider.

    Obtaining the stored procedures and their parameters from a database went pretty straightforward. But then executing them was a problem. I use a procedure to add parameters to an FbCommand.

    If I use:
    Code:
    void AddParameters(FbCommand ACommand)
    {
            ACommand.Parameters.Add("@UPWD", FbDbType.VarChar).Direction = ParameterDirection.Input; 
            ACommand.Parameters["@UPWD"].Value = (dgParameters.Items[0].Controls[5].Controls[1] as TextBox).Text.ToString();
            ACommand.Parameters.Add("@UNAME", FbDbType.VarChar).Direction = ParameterDirection.Input; 
            ACommand.Parameters["@UNAME"].Value = (dgParameters.Items[1].Controls[5].Controls[1] as TextBox).Text.ToString();
    }
    on 1 specific stored proc (sp_web_login) everything works just fine, and the results are what I expect them to be. But when I try to make it as flexible as I want it to be and use:
    Code:
        String CreateParameterName(DataGridItem Adi)
        {
            return "@" + (Adi.Controls[0] as TableCell).Text.ToString();
        }
        
        String GetDGValueString(DataGridItem Adi)
        {
            return (Adi.Controls[5].Controls[1] as TextBox).Text.ToString();
        }
            
        void AddParameters(FbCommand ACommand)
        {
            int index;
            DataGridItem di;
            lbParametersLoaded.Items.Add(dgParameters.Items.Count.ToString());
            
            for (index = 0; index < dgParameters.Items.Count; index++)
            {
                di = dgParameters.Items[index];
                if ( (di.Controls[4] as TableCell).Text.ToString() == "0")
                {
                    switch ((di.Controls[1] as TableCell).Text.ToString())
                    {
                        case "37" : //just varchar at the moment
                            ACommand.Parameters.Add(CreateParameterName(di), FbDbType.VarChar).Direction = ParameterDirection.Input; 
                            ACommand.Parameters[CreateParameterName(di)].Value = GetDGValueString(di);
                            
                            lbParametersLoaded.Items.Add("Varchar added " + CreateParameterName(di) + "Value " + GetDGValueString(di));
                            break;
                        default:
                            lbParametersLoaded.Items.Add("Default " + (di.Controls[1] as TableCell).Text.ToString());
                            break;
                    }
                }
            }
        }
    After a call to addParameters(myCommand) and creating a new FbDataAdapter adpt. The call
    adpt.Fill(ds, "Results");
    gives an error.

    As I can see it all the parameters are set in the same way, with the same name. Only in the second call the names are found in a datagrid.

    I use the latest net-provider. All the files I use in this project can be found on:
    source.zip

    I hope someone can shine a light on this problem, and thanks for taking the time to read this much text
  2. #2
  3. Bug Hunter
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    Transylvania (Romania)
    Posts
    309
    Rep Power
    23

    Lightbulb take a look on this thread


    http://forums.devshed.com/t65095/s.html

    i will take look on the code later
    Ps: there is a list for .net provider
    http://sourceforge.net/mailarchive/f...forum_id=12591
    and on the left corner is a search box
    My home page: http://www.firebirdsql.org and work place :http://www.reea.net

IMN logo majestic logo threadwatch logo seochat tools logo