开发者

Why do I get an SqlClientPermission exception?

I have built a C# WinForms application which accesses a SQL Server 2008 for data manipulation.

The application works fine on the machine that was developed on. However when开发者_开发问答 I copy the EXEs and move it to another computer (Windows XP), I got the following error during the login to the system (in other words, when i access the database).

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

Here's my connection string:

Data Source=vmsql;Integrated Security=SSPI;Initial Catalog=ChequeBookInventory

Stack trace is given in a screen shot

Any idea how to fix this issue?!


Most likely, the program is not executed with full trust. Either because the computer is configured like this or you are running it from a network share...
Some more info can be found here.


Grant the executing user rights to the database.


Well It was a combination of things that did the trick...

  1. Setup code level access... I had allow full trust on machine level that network share URL through .NET Fx configuration (Whc i had to install seperately)
  2. Install .NET latest version.. (I stuck to 3.5 ;-] )

Thanks for all the help guys :-)!!


If you want to connect to SQL Server remotely, and don't want use the username and password but Windows Authentication, that's just one way - "AD" ,I think AD might cause more problems (but AD is more secure), and I am really sorry about that my answer is not correct, I found some references about that issue,I think it might be help.

1.How to troubleshoot the "Cannot generate SSPI context" error message

2.“Cannot Generate SSPI Context” error message, more comments for SQL Server

3.“Cannot generate SSPI context” error message, when connect to local SQL Server outside domain

4.Service Principal Names (Windows)

5."Access Denied" error message when you try to access remote resources

that's bad answer bellow:

If you use "Integrated Security=SSPI", that means you can't connect to SQL Server remotely.

if you want to connect remotely, please use "User Id=myUsername;Password=myPassword;" instead of "Integrated Security=SSPI".

(Of course your SQL Server must accept "remote connection")connection string for connecting to data sources

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜