Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7542223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:06:36+00:00 2026-05-30T08:06:36+00:00

I am writing a generic sqldump utility that takes a DSN and a table

  • 0

I am writing a generic sqldump utility that takes a DSN and a table name and dumps the contents to a file. It’s an internal app so SQL Injection is not a serious threat, but I don’t want to have to worry about it. The thing is, the variable part of the query is actually the tablename, so the query is going to look like:

select * from [tablename];

…which I don’t imagine will work well with the OdbcCommand’s parameterized query support. I am also trying to support all types of DSN’s as generically as I can, regardless of the driver on the other side of the DSN.

Is there some universal way to sanitize my tablename input to protect against all SQL Injection using the OdbcCommand object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:06:37+00:00Added an answer on May 30, 2026 at 8:06 am

    I’d check the user input against the list of tables you know are there, using code roughly like what’s posted here to retrieve the table list (code from the link included for posterity):

    class Program
    {
      static void Main(string[] args)
      {
      string connectionString = GetConnectionString();
      using (SqlConnection connection = new SqlConnection(connectionString))
      {
       // Connect to the database then retrieve the schema information.
       connection.Open();
       DataTable table = connection.GetSchema("Tables");
    
       // Display the contents of the table.
       DisplayData(table);
       Console.WriteLine("Press any key to continue.");
       Console.ReadKey();
       }
     }
    

    That said, I agree with @KeithS above. This is probably a Bad Idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While writing several math utilities I bumped into need to implement generic utility that
I'm writing a Generic for LINQ to SQL CUD. I 'Generic Insert Public Shared
This is a generic C++ design question. I'm writing an application that uses a
I'm writing generic logger for SQLException and I'd like to get parameters that were
I am writing a generic function that will be reused in multiple places in
I am writing a Generic class that attempts to serialize an object of Type
I'm writing a generic template tag that could return a model's field value dynamically
I'm trying to writing a generic method that will load a record of a
I was writing a generic class to read RSS feed from various source and
I'm writing a generic class where I need to use Interlocked. T test1, test2;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.