O
Ook
Has anyone sucessfully connected a C# asp form to a MySQL database? If so,
would you care to share how you did it?
would you care to share how you did it?
Nicholas Paldino said:Ook,
If your ASP page is running on a different machine than the MySQL
database, then by default, you won't be able to connect. The reason for
this is that ASP.NET pages by defualt run under the local ASPNET user
account, which has limited rights. It doesn't have the right to open
network connections.
What you need to do is impersonate a user that has rights to the
database either through modification of the web.config file in the directory
the page is located, or by calling the Impersonate method on the
WindowsIndentity class.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Ook said:Has anyone sucessfully connected a C# asp form to a MySQL database? If so,
would you care to share how you did it?
Ook said:OK, now I'm confused
This application will be used by 50 users each sitting at their own
workstation. The MySQL database is sitting on yet another machine. Is this
not something that is easily done with c#?
message news:[email protected]...Ook,
If your ASP page is running on a different machine than the MySQL
database, then by default, you won't be able to connect. The reason for
this is that ASP.NET pages by defualt run under the local ASPNET user
account, which has limited rights. It doesn't have the right to open
network connections.
What you need to do is impersonate a user that has rights to the
database either through modification of the web.config file in the directory
the page is located, or by calling the Impersonate method on the
WindowsIndentity class.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Ook said:Has anyone sucessfully connected a C# asp form to a MySQL database? If so,
would you care to share how you did it?
Nicholas Paldino said:Ook,
If your ASP page is running on a different machine than the MySQL
database, then by default, you won't be able to connect. The reason for
this is that ASP.NET pages by defualt run under the local ASPNET user
account, which has limited rights. It doesn't have the right to open
network connections.
What you need to do is impersonate a user that has rights to the
database either through modification of the web.config file in the directory
the page is located, or by calling the Impersonate method on the
WindowsIndentity class.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Ook said:Has anyone sucessfully connected a C# asp form to a MySQL database? If so,
would you care to share how you did it?
Sami Vaaraniemi said:Comments inline:
message news:[email protected]...Ook,
If your ASP page is running on a different machine than the MySQL
database, then by default, you won't be able to connect. The reason for
this is that ASP.NET pages by defualt run under the local ASPNET user
account, which has limited rights. It doesn't have the right to open
network connections.
Huh? Are you sure about this? I can't test this right now but I doubt this
is the case.
What you need to do is impersonate a user that has rights to the
database either through modification of the web.config file in the directory
the page is located, or by calling the Impersonate method on the
WindowsIndentity class.
I've written an ASP.NET web app that connects to an MySQL database using the
ByteFX driver (http://www.bytefx.com/). The programming model is practically
identical to that of SqlClient, just the class names are different. There is
no need for impersonation, you just set up the database connection string asusual.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Ook said:Has anyone sucessfully connected a C# asp form to a MySQL database? If so,
would you care to share how you did it?
Nicholas Paldino said:Sami,
If your server is on the same machine as IIS is, then you will not have
a problem with this. However, if the MySql server is not the IIS machine,
then you will have to establish a network connection. The default settings
of an ASP.NET page prevent this from ocurring, and this is a common issue
with people using ASP.NET that are unaware of the security settings in it.