Use Table Name as a parameter ( For Dynamic table name) RRS feed

  • Question

  • hi to everyone i'm trying to send a table name as a argument but i'm getting an error  let me how to fix it

    my code is...

    public DataSet showQuestionAll(string tblName)
            string qry = "Select QName from @tblname";
            SqlCommand cmd = new SqlCommand(qry, conn);
            cmd.Parameters.AddWithValue("@tblname", tblName);
            SqlDataAdapter dt = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            return ds;


    Tuesday, September 15, 2015 12:52 PM


All replies