[Mono-list] Web Service cannot connect to Database
Timothy Graupmann
tgraupmann at yahoo.com
Thu Sep 29 11:51:39 EDT 2005
You are probably getting an access denied error. Did you setup the user on
localhost?
If you go to exterm and type
mysql -u root -p
what happens?
Here are some steps that I've used in the past.
http://www.tagcma.com/article.php?story=20050422023642167&query=mysql
And I think the localhost port is disabled for mysql by default. Editing the
config file to allow localhost networking.
~Tim
--- Joe Audette <joe_audette at yahoo.com> wrote:
> Hi,
>
> You did not mention what version of MySQL or the
> Connector. Newer versions of MySQL do not work with
> ByteFX and the last 2 releases (1.0.5 and 1.0.6) of
> the Connector do not work with mono so you would need
> 1.0.4.
>
> You say it works on Windows with this connection
> string
> string connectionString= "server=localhost;uid=root;
> pwd=koko; database=fotows";
>
> so localhost must be the windows box, when you move
> the code to mono either you are trying to connect to a
> different db because now localhost refers to the mono
> machine or else you need to change the connection
> string and put in the host name of the windows box
> (and make sure it can be resolved by the mono machine)
> or the ip address of the windows box
>
> Hope it helps,
>
> Joe
>
> --- Ko Ko <kkl_sg at yahoo.com> wrote:
>
> > Hi
> >
> > I got problem connecting to MySQL Database on Mono.
> > I can run the webservices. But when ever I try to
> > invoke the database from webservices it kept giving
> > me this error
> >
> > The remote server returned an error: (500) Internal
> > Server Error. Unable to connect to any of the
> > specified MySQL hosts
> >
> > I am using ByteFX and also MySQL connector/Net.
> > These are working fine on Windows Platform when I
> > tested with .Net. On Linux it cannot connect to
> > database. What could be the problem?
> >
> > I put the MySQL connector/Net version of code with
> > this mail.
> >
> >
> > using System;
> >
> > using System.Collections;
> >
> > using System.ComponentModel;
> >
> > using System.Data;
> >
> > using System.Diagnostics;
> >
> > using System.Web;
> >
> > using System.Web.Services;
> >
> > using MySql.Data.MySqlClient;
> >
> > namespace ws
> >
> > {
> >
> > /// <summary>
> >
> > /// Summary description for Service1.
> >
> > /// </summary>
> >
> > public class Fotohub :
> > System.Web.Services.WebService
> >
> > {
> >
> > public Fotohub()
> >
> > {
> >
> > //CODEGEN: This call is required by the ASP.NET Web
> > Services Designer
> >
> > InitializeComponent();
> >
> > }
> >
> > #region Component Designer generated code
> >
> >
> >
> > //Required by the Web Services Designer
> >
> > private IContainer components = null;
> >
> >
> >
> > /// <summary>
> >
> > /// Required method for Designer support - do not
> > modify
> >
> > /// the contents of this method with the code
> > editor.
> >
> > /// </summary>
> >
> > private void InitializeComponent()
> >
> > {
> >
> > }
> >
> > /// <summary>
> >
> > /// Clean up any resources being used.
> >
> > /// </summary>
> >
> > protected override void Dispose( bool disposing )
> >
> > {
> >
> > if(disposing && components != null)
> >
> > {
> >
> > components.Dispose();
> >
> > }
> >
> > base.Dispose(disposing);
> >
> > }
> >
> >
> >
> > #endregion
> >
> >
> >
> > [WebMethod]
> >
> > public DataSet GetUserInfo()
> >
> > {
> >
> > string connectionString= "server=localhost;
> > uid=root; pwd=koko; database=fotows";
> >
> > string query= "Select * From user";
> >
> > DataSet dataset=new DataSet();
> >
> > MySqlConnection conn = new
> > MySqlConnection(connectionString);
> >
> > MySqlDataAdapter adapter = new MySqlDataAdapter();
> >
> > adapter.SelectCommand = new MySqlCommand(query,
> > conn);
> >
> > adapter.Fill(dataset);
> >
> > return dataset;
> >
> > }
> >
> > }
> >
> > }
> >
> >
> >
> > regards,
> >
> > Ko Ko
> >
> >
> >
> >
> >
> >
> > Reality starts with Dream
> >
> >
> > ---------------------------------
> > Yahoo! for Good
> > Click here to donate to the Hurricane Katrina
> > relief effort. >
> _______________________________________________
> > Mono-list maillist - Mono-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >
>
>
> joe_audette [at] yahoo dotcom
> http://www.joeaudette.com
> http://www.mojoportal.com
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
More information about the Mono-list
mailing list