c# - Getting tables name in Console application -


i'm trying getting tables name in database, connection successful select query give me (system.data.sqlclient.sqlcommand) in result. below code.

sqlcommand cmd = new sqlcommand("select table_name dbname.tables"); console.writeline(cmd); string selectquery = "select * dbo.dbname"; sqlcommand = new sqlcommand(selectquery); console.writeline(a);  

attach output.enter image description here

first of must specify connection string

sqlcommand cmd = new sqlcommand("select table_name dbname.tables", connection_string); 

then must execute command->

using (sqldatareader reader = cmd.executereader()) {     while (reader.read())     {         console.writeline(reader[0]);     } } 

Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -