i want achieve this:
public void sqlinfo(string column) { sqlconnection connect = new sqlconnection( "server=server;database=db;user id=user;password=pass;"); connect.open(); sqlcommand com = new sqlcommand( "select distinct [column] [dbo].[serverattributes]"); sqldatareader reader = com.executereader(); }
i failed find documentation on this. there specific method use string passed through parameter within string? example, in powershell use '$' denote variable within string. "this $server you're working on."
yes can using string.format()
like
public void sqlinfo(string column) { string query = string.format("select distinct {0} [dbo].[serverattributes]", column); sqlcommand com = new sqlcommand(query); sqldatareader reader = com.executereader();
Comments
Post a Comment