Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

sql query in crm plugin

$
0
0

i write  this query in a crm plugin but i get this error 

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

SqlConnection myConnection = new SqlConnection("Data Source=........;Initial Catalog=......;Persist Security Info=True;User ID=sa;Password=.......;");
SqlCommand myCommand = new SqlCommand("[Depart]FROM [mbm_MSCRM].[dbo].[vwPayrollEmployees] WHERE [mbmhr_EmployeeNbr] =@EmpNbr", myConnection);
myCommand.Parameters.Add("@EmpNbr", empnbr);

myCommand.Connection = myConnection;
myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();

while (myReader.Read())
{
vdep = myReader["[Depart]"].ToString();

}
myConnection.Close();

i create this view (vwPayrollEmployees) in crm database 


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>