This is a migrated thread and some comments may be shown as answers.

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

1 Answer 55 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Shoji Kaburagi
Top achievements
Rank 1
Shoji Kaburagi asked on 12 Jan 2015, 03:16 PM
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?


















1 Answer, 1 is accepted

Sort by
0
Shoji Kaburagi
Top achievements
Rank 1
answered on 13 Jan 2015, 02:50 PM
This is my fault.

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

Thanks!
Tags
Report Designer (standalone)
Asked by
Shoji Kaburagi
Top achievements
Rank 1
Answers by
Shoji Kaburagi
Top achievements
Rank 1
Share this question
or