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);
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
Post a Comment