• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Variable schema names?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Variable schema names?

    I'm doing a bit of .Net work for a client who in turn wants to roll it out to several of their clients.
    All the end customers have the same (SQL Server) database, but the schema the tables live in varies.
    It's a real noddy little app, and I've dealt with it by putting the queries directly into the code,
    e.g.

    select ordernumber, orderdate, blah
    from [SCHEMA].[Order]
    Where
    clientId = @ClientId

    then doing a string Replace on "SCHEMA" with a value from the config file.

    This works, but doesn't seem like a great solution.

    If I create a SqlDataSource, it seems to allow me to run a replace on the SelectCommand.

    But if I use a TableAdapter (which is what I'd like to use - and was using before I realised they had different schemas) I can't access the underlying query through code.
    I've found some stuff about extending the TableAdapter but it doesn't seem to resolve my issue - I just want to access the original query and stick in my schema.

    I'm not going to fret too much over it, but wondered if anyone can suggest a better (and simple) solution?

Working...
X