ADO.NET Connection String

让人想犯罪 __ 提交于 2019-12-11 07:01:30

问题


I have a SQL Server 2008 database that uses a default schema called "Arxame". How do I specify or change the default schema from "dbo" to "Arxame" in my connection string? I'm using C# and ADO.NET.


回答1:


You can't do that. You have to set the schema "Arxame" to the user you have specified on your connection string. You can do this using the SQL Server Management tool

If you need to change the default schema for an existing user you can do it like this

B. Changing the default schema of a user

The following example changes the default schema of the user Mary51 to Purchasing.

USE AdventureWorks2008R2;
ALTER USER Mary51 WITH DEFAULT_SCHEMA = Purchasing;
GO

Source: MSDN




回答2:


The InitialCatalog is indeed the database name. The schema that is used would depend on the user you specify, since schemas typically map to database users. Whatever user owns the Arxame schema is the one you should specify in the connection string.




回答3:


I do not believe you can do this within a connection string, nor should you be able to. You use schemas, in much the same was as a namespace in C#, to further resolve securable objects within a database when there may be name collisions.

Schemas in SQL Server 2005 and up




回答4:


The initial schema must be set in your connection string:

Data Source=localhost;Initial Catalog=Arxame;Integrated Security=True

Remember to use Integrated security only if you are using a Local Sql Server.



来源:https://stackoverflow.com/questions/3589231/ado-net-connection-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!