Bug #91136 Object reference not set to an instance of an object
Submitted: 4 Jun 2018 15:13 Modified: 2 Jul 2019 19:11
Reporter: Jeffrey Roberts Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Visual Studio Integration Severity:S2 (Serious)
Version:1.2.8 OS:Windows (windows 10 Enterprise)
Assigned to: CPU Architecture:x86 (64-bit)
Tags: ADO.NET, Connector/Net, mysql for visual studio

[4 Jun 2018 15:13] Jeffrey Roberts
Description:
Provider MySql.Data.MySqlClient does not support the use of ASP:SqlDataSource via Visual Studio designer. According to the documentation, Connector/Net is a fully-managed ADO.NET driver for MySQL. According to Microsoft, the SqlDataSource is compatible with any ADO.NET driver.  In code I can create an instance of SqlDataSource, make a connection, and populate an ASP.NET control such as a GridView or DropDownList.  However, you cannot use the VS design environment to do the same.  I believe this used to work in prior releases.

MySql ODBC/Connector 8.0.11 also does not work for this purpose.  DSNs created for MySQL databases do not show as available when using ODBC from Visual Studio Connection Manager.  Oddly, I can see the MySQL ODBC DSNs in the Registry and can use them from Access.

How to repeat:
Microsoft Visual Studio Enterprise 2017 
Version 15.2 (26430.15) Release
VisualStudio.15.Release/15.2.0+26430.15
Microsoft .NET Framework
Version 4.6.1

MySQL for Visual Studio   1.2.8

-----
1. Create an empty C# Web App project.
2. Add Web Form.
3. Use Server Explorer to create connection to MySQL 8.0.11 and the world sample DB.
3. Drag SqlDataSource from VS Toolbox
4. Begin to configure the SqlDataSource via the wizard
5. Create a new connection using the connection created in step 3 above
6. Continue the SqlDataSource config by writing a custom query (SELECT Name FROM city).
7. Try to "Test Query" in the SqlDataSource wizard.  
8. Test fails.

If you try to use the SqlDataSource as the DataSource for a GridView (or anything else) it will fail at runtime with the 'Object reference not set to an instance of an object' which I'm guessing is related to the inability to test the query in the SqlDataSource wizard.

Oddly, you can use the Query Builder in the SqlDataSource wizard to construct and execute the query but it is still unusable as a DataSource.

Suggested fix:
Alas, I have no idea.
[4 Jun 2018 15:17] Jeffrey Roberts
Connector/NET 8.0.11
MySQL Server 8.0.11
MySQL for Visual Studio 1.2.8
Connector/ODBC 8.0.11
[7 Jun 2018 6:37] Chiranjeevi Battula
Hello Jeffrey Roberts,

Thank you for the bug report.
I could not repeat the issue at our end using with Visual Studio 2017, Connector/NET 8.0.11 and MySQL Visual Studio Integration 1.2.8 version.
Could you please provide a repeatable test case (exact steps/sample project, screenshot etc. - if you don't wish to make these public then please mark it as private) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[7 Jun 2018 12:04] Jeffrey Roberts
Step by step screenshots for Bug #91136

Attachment: Step by step screenshots for Bug .pdf (application/pdf, text), 685.08 KiB.

[7 Jun 2018 12:26] Jeffrey Roberts
I (appear) to have successfully uploaded the VS project zip file to sftp.oracle.com under the name mysql-bug-data-91136.zip
[7 Jun 2018 12:55] Chiranjeevi Battula
Hello Jeffrey Roberts,

Thank you for your feedback.
Verified this behavior on Visual Studio 2017, Connector/NET 8.0.11 and MySQL Visual Studio Integration 1.2.8 version.

Thanks,
Chiranjeevi.
[7 Jun 2018 12:56] Chiranjeevi Battula
Screenshot

Attachment: Bug_91136.PNG (image/png, text), 105.93 KiB.

[3 Aug 2018 12:49] Nicholas Anglin
Can also confirm this bug affects ASP:SqlDataSource added to aspx programmatically (as we do not use Designer).  Code-only connections via MySqlConnection do not appear to be affected.  Reverting to Connector/.NET 6.9.12 fixed was our temporary solution until this bug is resolved.
[13 Sep 2018 15:48] Jose Ramirez
Posted by developer:
 
Confirmed and reproduced behavior with MySQL for Visual Studio 1.2.8 and Connector/NET 6.10.8/8.0.12.
[13 Sep 2018 15:48] Jose Ramirez
Posted by developer:
 
Confirmed and reproduced behavior with MySQL for Visual Studio 1.2.8 and Connector/NET 6.10.8/8.0.12.
[17 Sep 2018 18:09] Akshay Kalwar
What is the status on this bug is it fixed yet?
[16 Oct 2018 21:14] Patrick Castillo
Hi, I too am interested if this bug is fixed yet

Patrick
[18 Feb 2019 14:24] Jeffrey Roberts
Any updates on this defect?
[2 Jul 2019 19:11] Christine Cole
Fixed as of the upcoming MySQL for Visual Studio 1.2.9 release, and here's the changelog entry:

From code, it was possible to create an instance of SqlDataSource, make a
connection to a MySQL server, and then populate an ASP.NET control.
However, attempting the same sequence using the Visual Studio Configure
Data Source designer produced a object-reference error when the data
source was being configured in the designer (and MySQL Connector/NET
6.10.8 was installed) and also at runtime of the web application. 

As part of a related fix, the data source now populates ASP.NET controls from
custom queries as expected at runtime. Likewise, the designer now permits
configuration when the 6.10.8 version of MySQL Connector/NET is installed
with one caution. When using the Specify columns from a table or view
option, the Configure Data Source designer generates the query using
bracket characters ( [] ) as delimiters for identifiers, which produces an
invalid MySQL statement. The brackets can be removed manually after the
data source is created. Alternatively, the second option in the designer
associated with generating queries from the data source, Specify a custom
SQL statement or stored procedure, is the preferred option to use.

Thank you for the bug report.