DKeeper

Same connection string works fine in Access 2003 VBA application but in VB.net it fails with a message of :

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

Dim sqlconn As SqlConnection = New SqlConnection("Data Source=CONFSQL02;Initial Catalog=MPP2007SQLB;user id=***;password=***")

Dim command As New SqlCommand(strsql, sqlconn)

Try

sqlconn.Open()

Catch

MsgBox(Err.Description)

End Try

Any ideas

Cheers



Re: Visual Basic Language sqlconnection

Fadi Nassri

i think that your form has no access to Database

try to Set the Security level to FULL TRUST level

i think this is can be done from Settings file






Re: Visual Basic Language sqlconnection

Riquel Dong ¨C MSFT

Hi Dkeeper,

Based on your post, when you access the database the request for the permission occurs.

As far as I know, the error information shows that your assembly doesn't have the SqlClientPermission to access the data source. The SqlClientPermission enables the .NET Framework Data Provider for SQL Server to help make sure that a user has a security level sufficient to access a data source. I also create one application which accesses a sql database. But I create a permission set and a code group. The permission set hasn't the SqlClientPermission. At last I add the application into this code group. When I run the application, the application shows the same information. I recommend you use .NET Configuration Tool to evaluate your assembly. You can use this tool to find out which code groups your assembly belongs to and which permissions the code groups have. If it doesn't have the SqlClientPermission, please grant this permission to your application. Please try it and let me know the result. Hope this helps.

Best regards,

Riquel