Search code examples
asp.netconnection-stringdatabase-schema

How to specify schema name in connectionstring in asp.net


How can I specify a schema name in SQL ConnectionString using ASP.net dynamically. I have a single database with multiple schema. I need to fetch data from table belonging to particular schema.


Solution

  • You can only specify the database and user details in the connection string.

    To retrieve data from a specific schema, you need to reference that schema in your query. For example;

    SELECT field1, field2 FROM [Schema].[Table]