Custom ADO.Net Provider Won't Show Data Source Parameters

2 posts, 0 answers
  1. Shoji Kaburagi
    Shoji Kaburagi avatar
    27 posts
    Member since:
    Jul 2012

    Posted 12 Jan 2015 Link to this post

    Hello.

    We have created a custom ADO.Net provider that accesses web service and returns a DataTable object. I have successfully inorporated into the Report Designer and everything works fine except when we have a parameterized SQL statement. When you create a data source with SqlClient Data Provider and it has a parameterized SQL statement a Data Source Parameters dialog box shows up where you can specify data types and default values. 

    The command class is inherited from DbCommand and adds parameters when CommandText was changed:
    public class AbstractCommand : DbCommand
    {
            private string commandText;
            private AbstractParameterCollection parameters;

    ...
            public override string CommandText
            {
                get
                {
                    return this.commandText; 
                }
                set
                {
                    this.commandText = value;
                    this.CreateParameters();
                }
            }

            protected override DbParameterCollection DbParameterCollection
            {
                get 
                {
                    if (this.parameters == null)
                    {
                        this.parameters = new AbstractParameterCollection();
                    }

                    return this.parameters;
                }
            }

            private void CreateParameters()
            {
                this.Parameters.Clear();
                if (this.commandText == null)
                {
                    return;
                }

                string[] lines = this.commandText.Split(new char[] { '@' });
                for (int i = 1; i < lines.Length; i++)
                {
                    string line = lines[i];
                    string[] split = line.Split(new char[] { ' ', '\t' });
                    if (split.Length == 0)
                    {
                        continue;
                    }
                    split = split[0].Split(Environment.NewLine.ToArray());
                    if (split.Length == 0)
                    {
                        continue;
                    }
                    this.Parameters.Add(
                        new AbstractDataParameter()
                        {
                            ParameterName = "@" + split[0],
                        });
                }
            }
    }

    I have comfired that the parameters are populated correctly and the dialog box still don't how.

    FYI, the config file has this:
    <system.data>
        <DbProviderFactories>
            <add name="Local Abstract Data Provider"
                 invariant="LocalAbstractDataProvider" 
                 description="Data Provider for Netsmart VR" 
                 type="LocalAbstractDataProvider.AbstractDbProviderFactory, LocalAbstractDataProvider, Version=1.0.0.0" />
        </DbProviderFactories>
    </system.data>  

    Do you have any idea?


















  2. Shoji Kaburagi
    Shoji Kaburagi avatar
    27 posts
    Member since:
    Jul 2012

    Posted 13 Jan 2015 in reply to Shoji Kaburagi Link to this post

    This is my fault.

    I did not implement all three DbConnection::GetSchema() methods. Once they are implemented, the dialog box is now showing.

    Thanks!
  3. DevCraft banner
Back to Top