c# - Reader for a MySqLConnection without database parameter in Connection String -
i'm trying run following query via datareader on mysql instance. reader returns null , understand due missing database parameter in connection string. how query work. need username, database name , hostname database i'm not sure database query same.
select current_user(), database(), @@hostname hostname;
the call made in following function , connection not specific database:
public databasedetails getdetailsdetails(connectiondetails details) { using (var dbcommand = details.connection.createcommand()) { dbcommand.commandtext = "select current_user(), database(), @@hostname hostname;"; using (var dr = dbcommand.executereader(commandbehavior.singlerow)) { return dr.read() ? new databasedetails { username = dbfunction.getstring(dr, 0), database = dbfunction.getstring(dr, 1), server = dbfunction.getstring(dr, 2) } : null; } } }
connection string used:
user id=root;password=***;data source=localhost;integrated security=false;auto enlist=true;
additional information: i'm not able top 20 records database table when put database name within query. datareader on debug shows rows of them "?". example following commandtext, no records:
select * db_sample.table_sample limit 20;
update: have worked way pull data table when database mentioned either in query or in connection string. need following mysql data server without knowing database (using query):
- database name
- host name
- user name
Comments
Post a Comment