473,382 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Using SqlDataSource with MySQL

Hi, I am trying to tie a SQLDataSource control to MySQL without
success. The connection string works ok with an ObjectDataSource.
(Native asp.net 2.0 MySQL dll loaded in /bin)

For some reason, the compiler believes an SQL db is being accessed ("An
error has occurred while establishing a connection to the server. When
connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)").

How can I modify the code so that the compiler "sees" a MySQL db?

Thanks for any hints, Mark
web.config:
<connectionStrings>
<add name="MySQLConn" connectionString=
"SERVER=localhost;DATABASE=dbKatoka;UID=admin;PWD= admin;"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>

aspx:
<%@ Import Namespace="MySql.Data.MySqlClient" %>
..
<asp:SqlDataSource id="Apts_City"
ConnectionString ="<%$ ConnectionStrings:MySQLConn %>"
SelectCommand="SELECT DISTINCT AptCity FROM tblApt;"
runat="server"/>

<asp:DropDownList id="DropDown1" DataSourceID="Apts_City"
DataTextField="AptCity" DataValueField="AptCity"
runat="server" />

Sep 17 '06 #1
5 7661
The SqlDataSource connects to SQL Server only. You will have to use an
OleDbDataSource with the proper provider for MySQL, or an OdbcDataSource
with the proper driver.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
<ms******@bluewin.chwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Hi, I am trying to tie a SQLDataSource control to MySQL without
success. The connection string works ok with an ObjectDataSource.
(Native asp.net 2.0 MySQL dll loaded in /bin)

For some reason, the compiler believes an SQL db is being accessed ("An
error has occurred while establishing a connection to the server. When
connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)").

How can I modify the code so that the compiler "sees" a MySQL db?

Thanks for any hints, Mark
web.config:
<connectionStrings>
<add name="MySQLConn" connectionString=
"SERVER=localhost;DATABASE=dbKatoka;UID=admin;PWD= admin;"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>

aspx:
<%@ Import Namespace="MySql.Data.MySqlClient" %>
..
<asp:SqlDataSource id="Apts_City"
ConnectionString ="<%$ ConnectionStrings:MySQLConn %>"
SelectCommand="SELECT DISTINCT AptCity FROM tblApt;"
runat="server"/>

<asp:DropDownList id="DropDown1" DataSourceID="Apts_City"
DataTextField="AptCity" DataValueField="AptCity"
runat="server" />

Sep 17 '06 #2
<ms******@bluewin.chwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Hi, I am trying to tie a SQLDataSource control to MySQL without
success. The connection string works ok with an ObjectDataSource.
(Native asp.net 2.0 MySQL dll loaded in /bin)
Hardly surprising...
For some reason, the compiler believes an SQL db is being accessed
Well of course it does - SQLDataSources are for connecting to SQL Server...
How can I modify the code so that the compiler "sees" a MySQL db?
Don't use an SQLDataSource - connect to your MySQL database "properly" i.e.
in code using the proper MySQL native .NET data provider...
Sep 17 '06 #3
Gregory,

I was about to type something similar too. But just in case I looked in the
MSDN:

------------------------------
By default, the SqlDataSource control works with the .NET Framework Data
Provider for SQL Server, but SqlDataSource is not Microsoft SQL
Server-specific. You can connect the SqlDataSource control with any database
product for which there is a managed ADO.NET provider. When used with the
System.Data.OleDb provider, the SqlDataSource can work with any OLE
DB-compliant database. When used with the System.Data.Odbc provider, the
SqlDataSource can be used with any ODBC driver and database, including IBM
DB2, MySQL, and PostgreSQL. When used with the System.Data.OracleClient
provider, the SqlDataSource can work with Oracle 8.1.7 databases and later.
The list of allowable providers is registered in the DbProviderFactories
section of the configuration file, either in the Machine.config or
Web.config file. For more information, see Selecting Data Using the
SqlDataSource Control.
------------------------------

Looks like it's a matter of proper connection to the MySql driver.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:%2****************@TK2MSFTNGP05.phx.gbl...
The SqlDataSource connects to SQL Server only. You will have to use an
OleDbDataSource with the proper provider for MySQL, or an OdbcDataSource
with the proper driver.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
<ms******@bluewin.chwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
>Hi, I am trying to tie a SQLDataSource control to MySQL without
success. The connection string works ok with an ObjectDataSource.
(Native asp.net 2.0 MySQL dll loaded in /bin)

For some reason, the compiler believes an SQL db is being accessed ("An
error has occurred while establishing a connection to the server. When
connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)").

How can I modify the code so that the compiler "sees" a MySQL db?

Thanks for any hints, Mark
web.config:
<connectionStrings>
<add name="MySQLConn" connectionString=
"SERVER=localhost;DATABASE=dbKatoka;UID=admin;PWD =admin;"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>

aspx:
<%@ Import Namespace="MySql.Data.MySqlClient" %>
..
<asp:SqlDataSource id="Apts_City"
ConnectionString ="<%$ ConnectionStrings:MySQLConn %>"
SelectCommand="SELECT DISTINCT AptCity FROM tblApt;"
runat="server"/>

<asp:DropDownList id="DropDown1" DataSourceID="Apts_City"
DataTextField="AptCity" DataValueField="AptCity"
runat="server" />


Sep 17 '06 #4
After some searching and experimenting, I got SQLDataSource tied up to
MySQL by using a ODBC 3.51 connection string:

web.config:
<add name="MySQL_ODBC"
connectionString= "DRIVER={MySQL ODBC 3.51 Driver};

SERVER=localhost;DATABASE=dbKatoka;UID=admin;PWD=a dmin;OPTION=3;"
providerName="System.Data.Odbc" />

aspx:
<%@ Import Namespace="System.Data.ODBC" %>
...
<asp:SqlDataSource ID="Apts_srcddnCity"
ConnectionString="<%$ ConnectionStrings:MySQL_ODBC %>"
ProviderName="<%$ ConnectionStrings:MySQL_ODBC.ProviderName %>"
SelectCommand="SELECT DISTINCT AptCity FROM tblApt;"
runat="server" />

<asp:DropDownList ID="DropDown1" DataSourceID="Apts_srcddnCity"
DataTextField="AptCity" DataValueField="AptCity"
runat="server" />

Sep 17 '06 #5
<ms******@bluewin.chwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
After some searching and experimenting, I got SQLDataSource tied up to
MySQL by using a ODBC 3.51 connection string:
This is almost certainly the least efficient method...
Sep 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: onearth | last post by:
Hello I managed to use SQL EXPRESS easily, however with MySql 5 or 4 I can't find any document explainning me how to use it :( The error i get is: The IListSource does not contain any data...
3
by: zapov | last post by:
Hi! Did anyone successfully managed to use some custom ADO.NET provider with SqlDataSource? I'd like to connect to some other database than MSSQL (like MySQL, Firebird or PostgreSQL) but I'm...
0
by: JimO | last post by:
Can anyone tell me if mysql and sqldatasource work together? I'm assuming it does not since I can't get any hits with a search on the MySQL website.
3
by: Daniel R. H. | last post by:
Hi, I'm having problems to get the value of a Querystring into the SelectCommand of a SQLDataSource, here's my code: ---------------------------------------------- <asp:SqlDataSource...
0
by: Mr Seth T | last post by:
I am creating a web app that needs to distribute to be able to be distributed to MySQL sites and Oracle sites. So far I have developed it for MySQL and now I am going back and adding Oracle...
0
by: Will | last post by:
I have searched and solutions that I have found are not working, I have a datagrid that will be updating a mysql db. Now I have a drop down that has a static collection but is dynamically selected...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
2
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
6
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.