Last post Feb 08, 2017 07:23 PM by lotusvball
Jun 06, 2015 03:55 AM|istakoza|LINK
I am trying to connect a Gridview to a MYSQL DB through a SQLDataSource. However, the SQLDataSource does not work or connect. I get the following error when I try to test my query:
Could not create connection
Exception o type 'Microsoft.VisualStudio.Web.Data.InternalException' was thrown.
I can connect to MYSQL DB from the code behind like this, therefor I must have the MYSQLConnectors working:
Using myConnection As New MySqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString) ......
But my SQLDataSource configured like this does not work.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" providerName="MySql.Data.MySqlClient"
ConnectionString="<%$ connectionStrings:ConnectionString %>"
SelectCommand="SELECT [email] FROM [my_aspnet_membership] ">
<asp:Parameter Name="email" />
Jun 06, 2015 08:06 PM|Lannie|LINK
Parameters are used to pass variable values to the select statement.. most often to a filtering WHERE clause...
we call these parameters BIND variable on the database side of the application.
In your example EMAIL is a COLUMN NAME, which is not a parameter value.
Select name, phone, email from my_aspnet_membership where email = :email
the :email is the call to the parameter you named parameter "email" in your pararmeter statement.
The COLON symbol tells MySQL and Oracle SQL client... that is a BIND variable awaiting population with parameter value.
To keep things separate from column names you might call your bind variable something else like bind_email or p_email
Also note when you have more than one parameter, they must be listed in the same order they are used.
Aug 02, 2016 02:25 PM|lotusvball|LINK
Have you figured this out. I am having the exact same issue and it has nothing to do with parameters since I don't have any.
Aug 04, 2016 10:31 PM|Lannie|LINK
Perhaps populating your Grid in Code Behind Form/Page instead of in the ASPX page using MS SQL style Tags will work.
Feb 08, 2017 07:23 PM|lotusvball|LINK
Perhaps you should answer the question. We already know how to do it with code but are asking why we are getting the error using the SQLDataSource wizard.