Thursday, March 22, 2007

Disconnected

When I first started cutting my teeth on dynamic web site development, I was pleased that Dreamweaver has plenty of tools to help out. Because we used it at work for sites, I chose the ASP.NET/C# server model, and used Access as the database (perfectly adequate for the size and features of the sites I was building).

Now I'm beginning to get to grips with PHP/mySQL for development. That's going well too. And having used mySQL for a while, I can see the advantages over Access. But what I'd really like to do is upsize a few of my Access databases to mySQL and have them connect to my existing .NET applications, without having to re-write the damned things.

The data migration tools available to s smooth job, and the data is sitting there, ready to go. But now I've hit a brick wall. How to tell Dreamweaver I want to use a mySQL database instead of access! So I began looking for the correct connection string, this was some help. I also downloaded MySQL ODBC 3.51 and installed it.

Then I set the web.config file entry to this (bold being the connection string given in the link above):


Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDatabase;User=myUser;
Password=myPassword;Option=3;" />



I tried the TEST button and Dreamweaver connected successfully! But try running the site via the browser (or Dreamweaver Live Data View) and it falls over with an error:
System.ArgumentException: An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
at System.Data.OleDb.OleDbConnectionString.ValidateParse()

So tried a different connection method, using Connector/Net 1.0.9 with this syntax in the web.config file - but got very similar results. Then I found this following in an Adobe Tech Note (my emphasis):
Do I have to use ODBC?
No. For ASP sites you can also connect to a database using OLEDB. For ASP.NET sites you must use OLEDB or the native ASP.NET SQL Server connector.
So it looks like it has to be OLEDB, but how to put the correct provider in the connection string? Nothing I've tried seems to work! Any clues? Has anybody actually got this combination to work?
  • Dreamweaver 8
  • ASP.NET/C# server model
  • mySQL database

1 comment:

Viken Govinden said...

Hi Caz, Just came across this post let's hope this helps, I had the same problem. I'm using it on my personal website for a few months now, and I had to move my codes around.

Please check : To import System.Data.Odbc

also place your connection string in asp tags & not in html script tags just under your imports as so :
"asp opening tag"@ Import Namespace="System.Data.Odbc"
"asp closing tag"

"asp opening tag"
Dim ConnStr As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDatabase;uid=userId;pwd=myPassword;option=3"
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
....
"asp closing tag"

(using "asp opening tag" as blog editor does not allow server-side scripting.)

or use ascx/include but do place it in asp tags only and above any html ones.

And the rest is done in script tags , that is queries etc.

But Dreamweaver did not support using MySQL driver with ASP.