Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Connecting a .net webservice to MySQL
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Connecting a .net webservice to MySQL

 Post Reply Post Reply Page  12>
Author
kfa View Drop Down
Newbie
Newbie


Joined: 10 April 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote kfa Quote  Post ReplyReply Direct Link To This Post Topic: Connecting a .net webservice to MySQL
    Posted: 10 April 2008 at 12:07pm
I have created a MySQL database on the server and want to connect through a .net web service written in C#. It works on my local computer using a MySQL Connector assembly, but this obviously doesn't work on the server. I guess it's not installed on the server, but then what?
 
Can anyone please give me an example of how to connect to a MySQL database in C#? Especially what using directives are required?
 
Thanks in advance!
Back to Top
jamie.townsend View Drop Down
Groupie
Groupie


Joined: 07 December 2007
Location: England
Status: Offline
Points: 114
Post Options Post Options   Thanks (0) Thanks(0)   Quote jamie.townsend Quote  Post ReplyReply Direct Link To This Post Posted: 10 April 2008 at 1:12pm
Hey, who is your hosting provider ?

Some hosting providers block third party class libaries so you may struggle with some.
Have you tried using myodbc ?
Back to Top
kfa View Drop Down
Newbie
Newbie


Joined: 10 April 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote kfa Quote  Post ReplyReply Direct Link To This Post Posted: 10 April 2008 at 1:25pm
Thanks for your reply.
 
It's hosted here at Webwiz Hosting. I just can't seem to find any documentation on how to setup the connection.
 
No, I haven't tried with myODBC, but I suppose it works similar to the MySQL Connector. Am I supposed to upload an assembly dll with one of the drivers mentioned, or does Webwiz hosting have some kind of connection driver installed, which I can use?
 
I'm quite new to this, so any help will be appreciated, thanks :-)
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 10 April 2008 at 1:28pm
mySQL not does work very well with mySQL although Microsoft are presently working on a driver to address this issue.

You should instead use SQL Server with ASP.NET as they are designed to work together and would give you much better performance and as all hosting packages come with SQL Server databases there is no reason to use mySQL with ASP.NET which I would suggest avoiding.


Edited by WebWiz-Bruce - 10 April 2008 at 2:26pm
Back to Top
kfa View Drop Down
Newbie
Newbie


Joined: 10 April 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote kfa Quote  Post ReplyReply Direct Link To This Post Posted: 10 April 2008 at 1:50pm
Bruce, did you mean "does NOT work very well"?
 
The reason why I want to use mySQL is that I'm working on a university project and we want the solution to be as platform independent as possible. Is there no possible way to connect to mySQL on the webwiz server? And in that case why are you offering mySQL databases?
 
Thanks again..
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 10 April 2008 at 2:53pm
mySQL is not normally used with ASP.NET but it is used with other supported technologies such as PHP and ASP. Although for ASP I would still recommend using SQL Server.

You can use the myODBC 3.51 driver which is installed on the servers to connect using ASP.NET.

A quick search on Google found the following page:-

http://www.freevbcode.com/ShowCode.asp?ID=6187

But you should be able to find other examples.


Edited by WebWiz-Bruce - 10 April 2008 at 3:04pm
Back to Top
kfa View Drop Down
Newbie
Newbie


Joined: 10 April 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote kfa Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2008 at 3:04pm
Thanks for your reply.
 
I've downloaded myODBC 3.51 from www.mysql.com. Now I'm just trying to get it to work on my own computer in my asp.net application (which is in C# btw).
 
Is it correct that ODBC should be able to connect both to a mySQL or an MSSQL database?
And is 'System.Data.Odbc' the only using directive needed to be able to connect?
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 12 April 2008 at 4:17pm
With SQL Server you should use the OLE driver it's much faster than ODBC.

Using different databases isn't as simple as just using ODBC. mySQL and SQL Server are very different and use different data types and different SQL.

mySQL is very good if you are using PHP, but in your case you should be using SQL Server with ASP.NET as this is ASP.NET's native database.

Using mySQL and ASP.NET would not give you the platform independence you are looking for but will give you no end of problems trying to get the two to work successfully together.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.