-
Notifications
You must be signed in to change notification settings - Fork 286
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
SQLCommand Error on Visual Studio Designer (WinForms) #1110
Comments
Hi @stavrinc, can you provide a repro app or more details? Are you trying to add a custom user control? How is |
I think the problem is that the designer component in visual studio is expecting to get a System.Data.SqlClient instance to design over but the instance is a Microsoft.Data.SqlClient ovject so the cast fails. You can see in the stack trace that it's trying to do design time stuff and then hits Microsoft.VSDesigner.Data.VS.SqlCommandDesigner and falls over, so i think visual studio would need to be updates to recognise this library instead of only the system version. |
The easiest thing to work with is a really really simple repro. Can you provide a sample project that shows the bug, so simple that you can just give someone the zip and tell them to open the designer, click a button and have it crash. |
I don't see a SqlCommand button so I'm assuming it's a custom user control. I'm not seeing the exception when I use the SqlClient library in a custom user control. Like Wraith2 said, please provide a basic application that others can run, otherwise it's difficult to figure out what's wrong. |
I'm pretty sure It's in the ancient visual studio SqlDataAdapter user interface that you can use to visually design table adapters and their commands. You can get at a command list and then edit the command properties directly. Getting a simple repro project setup in the breaking state would make it a lot easier to work out how to get it into the broken state though. |
Steps to reproduce the problem
I also provide link to a zip file with all files of a very simple project to reproduce the problem. https://mega.nz/file/78VCUBRB#K71u9vQc7aViMazRy5vYNAhn1i1N9MnMPtSlYSWFVLA |
The VS designers are tied to System.Data.SqlClient, avoid using them if you want to use M.D.S. |
Thanks, I'm able to repro it now.
Yes, I think this is right. |
Hi @stavrinc, with PR #1132 merged, data provider components will now use System.Data.SqlClient and not Microsoft.DataSqlClient. Future versions of VS may support Microsoft.Data.SqlClient but there are currently no plans for that. Here is the nuget if you would like to try it now: build artifacts Feel free to reopen if you have any more concerns. |
On a C# project (.NET Framework 4.8) when I try to create a control SqlCommand using the designer I get the following error
Failed to create component 'SqlCommand'. The error message follows: 'System.invalidCastException: Unable to cast object of type 'Microsoft.Data.SqlClient.SqlCommand' to type 'System.Data.SqlClient.SqlCommand'.
The same problem appears with Microsoft.Data.SqlClient V3 and V2.1.3 and older.
All other controls like SQLDataAdapter are ok.
Thanks in advance for any suggestion
The text was updated successfully, but these errors were encountered: