c# - Receiving error "no database selected" when trying to query DB -


i'm student in vocational high school , i'm still new programming, have assignment create application using c#, , have problem in joining 3 tables display on datagridview.. have tried query on mysql works fine, when applied in c# line of code didnt work shows "no database selected", can me on this, here's full code

string constring = "datasource=localhost;port=3306;username=root;password=root";         mysqlconnection condatabase = new mysqlconnection(constring);         mysqlcommand cmddatabase = new mysqlcommand("select book_detail.id_bookdetail, location.location_id, location.location_name, book.book_id, book.title location inner join book_detail on location.location_id = book_detail.location_id inner join book on book_detail.book_id = book.book_id; ", condatabase);         try         {             mysqldataadapter sda = new mysqldataadapter();             sda.selectcommand = cmddatabase;             datatable dbdataset = new datatable();             sda.fill(dbdataset);             bindingsource bsource = new bindingsource();              bsource.datasource = dbdataset;             transfer_view.datasource = bsource;             sda.update(dbdataset);         }         catch (exception ex)         {             messagebox.show(ex.message);         } 

your connection string should specify database name:

server=myserveraddress;database=mydatabase;uid=myusername;pwd=mypassword;                        ^^^^^^^^^^^^^^^^^^^ 

(port 3306 default mysql port)

ref. mysql connection strings


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -