Soheyl Soheyl - 1 year ago 114
MySQL Question

C# How add mysql connection to separated class?

Is it possible to add MySQL connection to another Class (as public) in C# and call the connection in other classes instant of typing all connection code lines every time and for each part of the program ?

Is it secure and correct to do something like that ?

For EX, in PHP we can use include, is any other way in C# to do the same ?

I know we can use Public classes in C# and call them in other part of program, like using function in PHP, so I would like to know if it's secure to use same method in C# for MySQL connection !

And finally, if someone can explain me how to make it happen (have MySQL connection in separated class) or send me a link where it explain that !

Answer Source

Well, as I learned, it's not a good idea to use MYSQL connection info into the app and so I just created a PHP file on my server and I use webclient post to send and receive data to and from the PHP file and I have my database connection into my PHP file too.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download