0

I have developed a website in which I have used ASP.NET with VB.NET as the backend programming language and a MySQL database. I have used ASP.NET and the MySQL database connector to run the website on my local computer, and it is working fine. The code of web.config file is given below:

<?xml version="1.0"?>
<!--
    For more information on how to configure your ASP.NET application, please
    visit
    http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
    <system.web>
        <trust level="Medium"/>
        <customErrors mode="Off" defaultRedirect="Home.aspx"/>
        <compilation debug="true" strict="false" explicit="true"
                     targetFramework="4.0">
            <assemblies>
                <add assembly="MySql.Data, Version=6.9.9.0, Culture=neutral,
                     PublicKeyToken=C5687FC88969C44D"/>
            </assemblies>
        </compilation>
    </system.web>
</configuration>

But now I have uploaded this website and database on the global server and have put the global database connection in my code. now the code of web.config file is

<?xml version="1.0"?>
<!--
    For more information on how to configure your ASP.NET application, please
    visit
    http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
    <connectionStrings>
        <add name="myConnectionString" connectionString= "Server=globalservername;
             Database=databasename; Uid=userid; Pwd=passwd;"
             providerName="MySql.Data.MySqlClient" />
    </connectionStrings>
    <system.web>
        <trust level="Medium"/>
        <customErrors mode="Off" defaultRedirect="Home.aspx"/>
        <compilation debug="true" strict="false" explicit="true"
                     targetFramework="4.0">
        </compilation>
    </system.web>
</configuration>

And when I open any page then it is showing the following error

Compiler Error Message: BC30002: Type 'MySqlConnection' is not defined.

in this line which is in every Visual Basic file of my project (connection string):

Dim SQLConnection As New MySqlConnection("Server=globalservername;
Database=databasename; Uid=userid; Pwd=passwd;")

What should I add or remove in the web.config file to remove this error?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Deepak Tomar
  • 57
  • 1
  • 7

2 Answers2

0

You might be missing the required DLL file, MySQL.Data in a production environment. You can use the NuGet package* MySQL.Data* then build and deploy.

Alternatively, you can place the MySQL.Data DLL file in your bin folder and deploy.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Do this first:

Mysqlopen("db")

It should work. If not, then make sure you have VB 2005. It will not work with Visual Basic 6.0. If that doesn't work then you can just run the SQL as a separate process and use Visual Basic to to call it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131