How can I connect to mysql in custom module?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/4/2010 4:03:59 PM
Gravatar
Total Posts 23

How can I connect to mysql in custom module?

My website is based on Mojoportal and the database is Mysql.  Now it can work. Now I am developing some program based on HelloMojoSiteModule. Firstly I develop the program with mssql. So it can work and I can visit the table in mssql. But when I immigrate the program into mysql there  is not proivder to connect to mysql. I think mojoportal can visit mysql. I think it's very easy for me to connect mysql too.

Best regards

 

Scott Liu

6/5/2010 12:54:54 PM
Gravatar
Total Posts 18439

Re: How can I connect to mysql in custom module?

Hi Scott,

If you want to work directly with the MySql provider you could add

<%@ Import Namespace="MySql.Data.MySqlClient" %>

or you could add this:

<%@ Import Namespace="mojoPortal.Data" %>

which should allow you to use our MySqlHelper class which has methods such as ExecuteReader, ExecuteNonoQuery, ExecuteScalar

You can study mojoportal source code in the data layer for MySql to find good examples.

We also have a SavedQuery class that lets you save and retrieve query statements and our DatabaseHelper which helps execute them, useful for quick and dirty features but not how I would typically develop anything complex. There is an article here http://www.mojoportal.com/populating-a-chart-with-data-from-a-saved-query.aspx and also an article here about our built in query tool http://www.mojoportal.com/using-the-sql-query-tool.aspx

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.