I'm trying to call the stored procedure, xp_fixeddrives, from an InfoPath 2010 but need to make it 2003 compatible if possible. I'm familiar with doing C# coding in the form but calling this stored procedure has me stumped. I'm getting the following exception on the connection.Open() statement below. I'm an admin on the development machine (Win 7/SharePoint installed directly on it) and I have db_owner permissions on the database.
System.Security.SecurityException was unhandled by user code
Message="Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib"
Code sample:
string connString = "Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=WSS_NTLMOnlyContent;Data Source=.\\Sharepoint;";using (SqlConnection connection = new SqlConnection(connString))
{
// Create the command and set its properties.SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "xp_fixeddrives";
command.CommandType =
CommandType.StoredProcedure;
// Open the connection and execute the reader.
connection.Open();
// getting permissions issueSqlDataReader reader = command.ExecuteReader();if (reader.HasRows)
{
while (reader.Read())
{
Console.WriteLine("{0}: {1:C}", reader[0], reader[1]);
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
}
// end using
Does anyone have ideas?