Wednesday, 24 February 2016

How to Connect to MySQL Database Using Web ExpressionIn Feburary 2016 24,

In Feburary 2016 24,
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.
Copy the following code:
Now click in the Code section of the target website in Expression Web, above where the code reads:
Right-click above
and choose 'Paste' to paste the copied code. It should now look like this:
Copy the following code:
Sub Page_Load(Source as object, e as EventArgs)Dim sConString As String = 'DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=Your_Mysql_DB; UID=mysql_username; PASSWORD=mysql_password; OPTION=3'Dim oConnection as ODBCConnection = new ODBCConnection(sConString)Dim sSQL as String = 'SELECT * FROM Table1'Dim oDataAdapter as ODBCDataAdapter = New ODBCDataAdapter(sSQL, oConnection)Dim oDataSet as DataSet = new DataSet()oDataAdapter.Fill(oDataSet)oDataGrid.DataSource = oDataSetoDataGrid.DataBind()End Sub
Click again in the Code section of the target website in Expression Web. Paste the code after the
tag in the code for the website. Be certain that the
tag closes the code section.Copy this line: Paste it between the
and
tags, also in the Code section of the target site in Expression Web.Example:
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.
In Feburary 2016 24,

No comments:

Post a Comment