开发者

Problem accessing sql server database 2008 r2 over network

开发者 https://www.devze.com 2023-04-09 06:47 出处:网络
I\'ve just finished my c# application with sql database built in 2008 r2 version I wanted to share this database over LAN and my connection string is :

I've just finished my c# application with sql database built in 2008 r2 version

I wanted to share this database over LAN and my connection string is :

ConnectionString = @"Data Source=192.168.0.1,1433\SQLEXPRESS;user id=Rula; password=marojo;AttachDbFilename=\\192.168.0.1\Release\WEPA.mdf;Connection Timeout=30;Integrated Security=SSPI;user instance=true";

where 192.168.0.1 is the IP of the computer hosting the sqlexpress instance

when I connect to database locally from the hosting computer I get no errors, but when I try to connect to the database from the shared application I get the following error:

User doesn't have permission to perform this action.

while I mapped the GUEST user to my database on the hosting machine since I knew that if a computer try to connect to database remotly, it connect as guest.

not开发者_如何转开发ice: I have my application and database shared over network in the same folder, and again locally everything is ok

Please what can I do to solve this problem ???? thanks in advance =-)


If the 2 machines are not on the same domain this will fail. You might want to use sql logins


The guest account would not be used in an trusted connection. The integrated connection uses the user account attached to the process using the connection string.
http://forums.asp.net/t/822604.aspx/1

If you wanted to use integrated security, the web server would need to be configured to digest logins and then you would need to grant access to all (potential) authenticated users access to the database. This is typically not done due to the unnecessary complexity you are adding to the process. Just use sql links like Ali stated and be done with it.


Okay, I see a couple things that are wrong in your connection string.

Namely, you have defined a user id and password... then you go on to set the Integrated Security flag. These are mutually exclusive. Either it connects as the same user that the app is executing under (most likely the app pool user account) OR it connects as the user defined in your connection string.

The reason you see a difference between 7 and XP is simply that one is defaulting to using the user id / password, the other is defaulting to using integrated security.

I suggest that you visit http://www.connectionstrings.com/ in order to build a proper connection string.

Update:

Other things I see. First, AttachDbFilename can only work with integrated security. Obviously that isn't a possibility, so you need to get rid of that parameter and configure sqlexpress directly on the server to target that database file.

Second, User Instance is for desktop deployments.. not servers. Get rid of it as well because it's going to be a huge memory hog.

Third, read this: http://msdn.microsoft.com/en-us/library/ms247257(v=VS.100).aspx


There are quite a few reasons this could be happening:

  1. SQL Browser service not turned on
  2. Connection string using a trusted connection and you are not set up as that user (check what user your code is using by getting User from the current context)
  3. You do not have the same protocols set up on the client (less likely)

Since it is a permissions issue, you will most likely have to set up your windows domain account in the database to use it. If that is not an option for the application users, then you may desire to move to a sql account rather than windows accounts.


problem solved !!

there was just attaching problem when the database is attached to sql server management studio it's attached as an old name or related to the computer it's copied from

Thank you everyone for your effort : )

0

精彩评论

暂无评论...
验证码 换一张
取 消