MySQL Forums
Forum List  »  MySQL for Visual Studio

Re: Saving Visual Studio 2010 express pages as MySQL
Posted by: Francisco Alberto Tirado Zavala
Date: August 07, 2015 11:29AM

Hello Lynn.

Basis on what you're describing, I'll assume that you're using the SqlDataSource object as DataSource in your Gridviews.
Since the SQLDataSource is an object provided by the .Net framework I can tell you that is not a MySql bug or anything related because is not part of MySql for Visual Studio or Connector/Net.

But you have two more workarounds besides write the queries by yourself:
1- The hard one, You can add the Selecting, Inserting, Deleting, Updating methods to the SqlDataSource and in that method remove the characters that are not valid for MySql syntax, for example:

protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
//replace the braquets that are not valid for MySql with empty string
e.Command.CommandText = e.Command.CommandText.Replace("[", "").Replace("]", "");
}

2- The easy one, You can edit manually the queries configured for the SqlDataSource, open the .aspx file where is placed your GridView and then click on the "Source" tab that normally is placed at the bottom left of the document open, when you click on the tab you will see the ASP.Net code of the controls that are in your page. Once you locate the SqlDataSource code you will see the queries configured for Select, Insert, Update and Delete so there you can remove the characters that are not valid for MySql syntax, for example I removed the braquets "[]" from the following code that I used as test:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sakilaConnectionString %>" DeleteCommand="DELETE FROM actor WHERE actor_id = ?" InsertCommand="INSERT INTO actor (actor_id, first_name, last_name, last_update) VALUES (?, ?, ?, ?)" OnSelecting="SqlDataSource1_Selecting" ProviderName="<%$ ConnectionStrings:sakilaConnectionString.ProviderName %>" SelectCommand="SELECT * FROM actor" UpdateCommand="UPDATE actor SET first_name = ?, last_name = ?, last_update = ? WHERE actor_id = ?">
<DeleteParameters>
<asp:Parameter Name="actor_id" Type="Int16" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="actor_id" Type="Int16" />
<asp:Parameter Name="first_name" Type="String" />
<asp:Parameter Name="last_name" Type="String" />
<asp:Parameter Name="last_update" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="first_name" Type="String" />
<asp:Parameter Name="last_name" Type="String" />
<asp:Parameter Name="last_update" Type="DateTime" />
<asp:Parameter Name="actor_id" Type="Int16" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks for your time.

*** My opinions do not necessarily reflect the opinions of my employeer ***
MySql Windows Experience Team

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Saving Visual Studio 2010 express pages as MySQL
812
August 07, 2015 11:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.