Hi guys,

i'm trying to test my asp.net app. it works fine when in visual studio 2010 ide, connecting to Mysql database and running. but, when testing in IIS the published app get the message exception "no database selected".

it's everything running local, windows xp, mysql 5.x, IIS 5.1

my connection string: connectionString= "database=mariacandelaria;data source=localhost;User Id=dboMariaCandelar;Password=Blu32010;" this is the code in c#

private void GetInfoConectado (long user) {
            string uc;
            uc = user.ToString();
            /* Generamos un query a BD */
            MySqlConnection cn = new MySqlConnection(this.conexion);
            MySqlCommand command = new MySqlCommand(
                "SELECT * "
            + "FROM opeTabla "
            + " where idRep = " + uc
            , cn);
            MySqlDataReader reader=null;            
            
            cn.Open();            
            reader = command.ExecuteReader();
...

message appears in last line i wrote.


thanks for your help.

A mysql connection string is normally server="" database="" uid="" pwd="". I could be wrong but I didn't think data source was valid.

Change the connection string,

connectionString= "Database=mariacandelaria;Server=localhost;uid=dboMariaCandelar;pwd=Blu32010;"

Change the connection string,

connectionString= "Database=mariacandelaria;Server=localhost;uid=dboMariaCandelar;pwd=Blu32010;"

thanks for helping hericles and adatapost,
now i get this

Detalles de la excepción: MySql.Data.MySqlClient.MySqlException: Access denied for user ''@'localhost' to database 'mariacandelaria'

Error de código fuente: 


Línea 72: 
Línea 73:             cn.Open();            
Línea 74:             reader = command.ExecuteReader();
Línea 75: 
Línea 76:             if (reader != null && reader.HasRows)

seems .net MySql.Data doesn´t match fields for connection. or is correct to not show username in exception reported?

still works fine with new string conn inside Ide vs2010, doesn't work only in IIS.

greetings

you might try replacing localhost with 127.0.0.1

You might also try going through the MySQL Causes of Access Denied Errors page.

change testing on windows seven, iis 7, and vs 2010 and works fine. now i'll get configuration on final site and test there. hope it isn't iis 5.1.

when finish installing report and close this thread.

see you

Hello everyone.

i've founded the defect on code.
it seems on examples (to get connection string from web.config file) i saw something like

System.Configuration.Configuration rootWebConfig =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("\\Maria Candelaria");
            System.Configuration.ConnectionStringSettings connString;

            if (0 < rootWebConfig.ConnectionStrings.ConnectionStrings.Count)
            {
                connString =
                    rootWebConfig.ConnectionStrings.ConnectionStrings["MariaCandelaria"];

where

OpenWebConfiguration("\\Maria Candelaria");

was like

OpenWebConfiguration("/web.config");

so i assumed it was rigth and didn't read complete document. i let it just like example was.

Surprisingly inside ide vs 2010 it works fine. even if you code "cow's have 4 legs" instead of web.config.
but...when running for browser or inside iis, it must be the name of the web site. at this moment don't know yet if there is a way to name web site in vs2010 but isn't necesary it seems.

but i'm happy it's solved, just using there the name of the web site, just like documents say. next time i'll try to read carefully, there's even a NOTE marking this.

now i can deploy my website.

http://msdn.microsoft.com/en-us/library/ms178411.aspx

thanks everyone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.