How to Connect to MySQL Database Using Web Expression

By Sasha Maggio

A MySQL database can quite easily be set up to connect through a website using Microsoft Expression Web. Expression Web does not have a special "connect to MySQL" feature, however, so the code must be entered manually into the code section of the target Web page within Expression Web. This may seem intimidating to some, especially if the designer does not have knowledge of this type of code work, but simply copying and pasting predesigned MySQL database code and changing a couple of necessary items is really all this takes.

Things You'll Need

  • MySQL database software

Step 1

Open Microsoft Expression Web. Click on "File," "Open" and choose the target website from the website files. Click "Split" below the design pane. The three tabs below the design pane are Design, Split and Code; Split shrinks the size of the design pane and opens up the Code section above it, where HTML code is entered.

Step 2

Copy the following code:<%@ Page CompilerOptions='/R:"C:\Program Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll"'%><%@ Import Namespace="System.Data" %><%@ Import Namespace="Microsoft.Data.Odbc" %>Now click in the Code section of the target website in Expression Web, above where the code reads:

Right-click aboveand choose "Paste" to paste the copied code. It should now look like this:<%@ Page CompilerOptions='/R:"C:\Program Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll"'%><%@ Import Namespace="System.Data" %><%@ Import Namespace="Microsoft.Data.Odbc" %>

Step 3

Copy the following code:

Click again in the Code section of the target website in Expression Web. Paste the code after thetag in the code for the website. Be certain that thetag closes the code section.Copy this line:Paste it between theandtags, also in the Code section of the target site in Expression Web.Example:

Step 4

Note the line in the MySQL database code that reads: "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=Your_Mysql_DB; UID=mysql_username; PASSWORD=mysql_password; OPTION=3"These values will need to be changed to represent the desired MySQL database, ID and password. If the database is to be accessed remotely, the "server" will be an IP address. Simply delete the "answer" following the equal sign (=) for each item and type in the correct information.

Tips & Warnings

  • Save the work often to avoid accidentally losing changes made to the website or Web pages in the event of the Expression Web program or computer freezing, a power surge or other unfortunate and unpredictable occurrence.