3 Replies - 7327 Views - Last Post: 29 April 2013 - 02:40 AM

#1 warbie118  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 02-December 11

Connecting to Mysql database problem

Posted 09 March 2013 - 04:27 PM

Hi, I am having trouble connecting to a Mysql database for a restful api i am developing,

using MySql.Data.MySqlClient;
this is whaat i am using in my dblayer

 <assemblies>
        <add assembly="MySql.Web, Version=6.1.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
        <add assembly="MySql.Data, Version=6.1.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
      </assemblies>
This is the assemblies in my web.config

<connectionStrings>
    <add name="******" connectionString="Server=*****;Persist Security Info=True;Database=mwarburton;Uid=*****;Pwd=*****" providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
and this is my connectionstring in web.config

when i try to run my restful api on Postman a google chrome application i get the following error

Posted Image



If someone could please tell me how i can solve this and connect to my database it would be a great help as its getting really frustrating now!!

Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: Connecting to Mysql database problem

#2 codejunky  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 18-April 13

Re: Connecting to Mysql database problem

Posted 27 April 2013 - 02:28 AM

Not sure about doing it like that but c# MySQL.Data.MySqlClient;
I connect like

 string constring = @"server=yourserver;port=yourport;userid=youruserid;
            password=yourpassword;database=yourdatabase";

            MySqlConnection connect;
            connect = new MySqlConnection(constring);
            MySqlCommand cmdDataBase = new MySqlCommand("select * from yourdatabase.yourtable", connect);
            MySqlDataReader myReader;
          
            try
            {      
            connect.Open();                              
            myReader = cmdDataBase.ExecuteReader();
          
            while (myReader.Read())
            {
               
            }
           
            }
            catch (MySqlException ex)
            {
                 MessageBox.Show(ex.Message);

            }
            

Was This Post Helpful? 0
  • +
  • -

#3 andy_pleasants  Icon User is offline

  • D.I.C Head

Reputation: 41
  • View blog
  • Posts: 122
  • Joined: 08-July 10

Re: Connecting to Mysql database problem

Posted 29 April 2013 - 02:18 AM

I think this is more of a .NET related problem than a MySQL problem. The error says it can't load the required assembly, you might have more look on the .NET board
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

Re: Connecting to Mysql database problem

Posted 29 April 2013 - 02:40 AM

Andy is right. I've moved this thread over to the .NET forum.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1