| Author |
Topic Search Topic Options
|
kfa
Newbie
Joined: 10 April 2008
Status: Offline
Points: 6
|
Post Options
Thanks(0)
Quote Reply
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!
|
 |
jamie.townsend
Groupie
Joined: 07 December 2007
Location: England
Status: Offline
Points: 114
|
Post Options
Thanks(0)
Quote Reply
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 ?
|
 |
kfa
Newbie
Joined: 10 April 2008
Status: Offline
Points: 6
|
Post Options
Thanks(0)
Quote Reply
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 :-)
|
 |
WebWiz-Bruce
Admin Group
Web Wiz Developer
Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
|
Post Options
Thanks(0)
Quote Reply
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
|
|
|
 |
kfa
Newbie
Joined: 10 April 2008
Status: Offline
Points: 6
|
Post Options
Thanks(0)
Quote Reply
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..
|
 |
WebWiz-Bruce
Admin Group
Web Wiz Developer
Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
|
Post Options
Thanks(0)
Quote Reply
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
|
|
|
 |
kfa
Newbie
Joined: 10 April 2008
Status: Offline
Points: 6
|
Post Options
Thanks(0)
Quote Reply
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?
|
 |
WebWiz-Bruce
Admin Group
Web Wiz Developer
Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
|
Post Options
Thanks(0)
Quote Reply
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.
|
|
|
 |