CR with visual studio 2010 logon box - visual-studio-2010

We are using CR with Visual studio 2010 for our applicaton.
Following is the code which I am using for generating the report from collection of objects which I got from Webservice.
SampleReport report = new SampleReport();
report.SetDataSource(response.Items);
Then at WPF level, I am assigning report source to the viewer as follows.
this.reportViewer.ViewerCore.ReportSource = report;
Problem is it is asking me login credential. Which I believe interesting as All the information to generate the report is ready to be picked up from the collection assigned as datasource.
Let me know what these credential could be. or how to override the behaviour.
Note: The designer had designed the .rpt file from xml, that WCF service provided.
I have looked around in forums for solutions, they dont have much information except following :
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Tables CrTables ;
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
The problem is, I can understand if I would be connecting to DB to get the data... But getting data from object collection should not require the credential.

I faced such a problem earlier. What I did to fix this:
In the Visual Studio designer make sure that the Crystal Report Viewer doesn't have a report source defined
In the Crystal Report designer open the Field Explorer and right click on Database Fields and make sure you have selected the correct database location using the Set Database location, also try the Log On or Off Server
This is part of the code to load the report:
rptDoc.Load("CrystalReport_Test.rpt")
rptDoc.SetDataSource(rptDataset)
CrystalReportViewer1.ReportSource = rptDoc
CrystalReportViewer1.RefreshReport()
Hope this helps.

Related

Why is MdiActiveDocument null in the beginning in AutoCAD 2015+?

I am working in AutoCAD 2014 using Visual Studio 2013.
With my code I access the MdiActiveDocument's database from the DocumentManager .
Using the database I start a transaction and use the GetObject method of the transaction to retrieve Entity objects.
Database acCurDb = Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
var obj = acTrans.GetObject(id, OpenMode.ForRead);
if (obj is Entity)
{
// do stuff
}
acTrans.Commit();
}
This works fine while I am in development and start AutoCAD from inside of Visual Studio. In development I set the "Start external program" switch in the Debug tab of the application properties so it starts AutoCAD for me and everything works great.
The issue I am having is that in production when the app is loaded by AutoCAD via registry settings (I use demand loading) the MdiActiveDocument is null so the code crashes. I have discovered there is a document in the Application.DocumentManager but when I assign the database from that document to acCurDb the TransactionManager throws an error with I try to use the StartTransaction method.
if (Application.DocumentManager.Count > 0)
{
foreach(Document doc in Application.DocumentManager)
{
acCurDb = doc.Database;
break;
}
}
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
}
Can someone help me understand why the MdiActiveDocument is null and/or direct me to the proper way to get a Transaction object in AutoCAD?
Beginning in 2015, AutoCAD may have a null active document on startup depending on user system variables. It's just another check you have to add before running your routine.
As mentioned by #david-wolfe, AutoCAD 2015 may start with no active document (just a dashboard). In this case the MdiActiveDocument can be null.
Now you're on AutoCAD 2014, so a different scenario may happen: if your app is loading with AutoCAD, you code may run before anything is really ready. How are you running the code? Is it a CommandMethod? If is a command, the user can only run it from a command, so it will be a active document. But if you run it from other method (like direct call from the Ribbon or from a palette), it may be null.

Error 0152: No Entity Framework provider found for 'Oracle.DataAccess.Client' ADO.NET provider

I have Windows 7 x64, Visual Studio 2012 with the 'ODAC 11.2 Release 5 and Oracle Developer Tools for Visual Studio (11.2.0.3.20)'.
Then I connected to Oracle db, create .edmx model. But when I'm trying to use EF to operate some data
var ent = new Entities();
var res = ent.table1.ToList();
Error happends
Schema specified is not valid. Errors:
Model.ssdl(2,2) : error 0152: No Entity Framework provider found for
'Oracle.DataAccess.Client' ADO.NET provider. Make sure the provider is registered in
the 'entityFramework' section of the application config file. See
http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
I checked my AppConfig, all sections are ok. Also I installed ODAC1120320Xcopy_x64 (and added a environment variables too). But nothing changes.
If I do it in this way, all works fine
EntityConnection econn = new EntityConnection("name=Entities");
econn.Open();
EntityCommand ecmd = econn.CreateCommand();
ecmd.CommandText = "SELECT e.NAME FROM Entities.table1 as e";
EntityDataReader ereader = ecmd.ExecuteReader(CommandBehavior.SequentialAccess);
while (ereader.Read()) { ... }
Have you any ideas? Will be very grateful for any help.

Open form using webpart

I'm a problem to open a infopath form using XmlFormView. Here you have the code:
SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
try
{
XmlFormView form = new XmlFormView();
String templateLib = "FormServerTemplates";
String xsnName = report + ".xsn";
form.XsnLocation = String.Format("{0}/{1}/{2}", SPContext.Current.Web.Url, templateLib, xsnName);
manager.AddWebPart(form, "TopZone", 0);
}
So I create a page and I add a xmlform webpart to see infopath report in a page. The problem is when I try to open the page:
A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file.
Correlation ID:51a2dcd8-d2fa-4d8b-ae13-1b5f9caa1c51
It's weird becouse I can open the same form when I click on the content type that i assigned in a document library, but in a page, it's impossible to see it. What's going on here?
Thank you
First, can you check the exception in the SharePoint logs and add it to the post?
They are located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\LOGS. You can use the correlation ID to find the exception.
Additionally, try using elevated privileges like this:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// your code here
});

MVC WebAPI returning 500 error with no information

I've been having this problem for several days (now fixed and solution noted for anyone that comes across this issue and is pulling their hair out).
After my latest round of code changes to my Silverlight application which uses MVC4 WebAPI for data, I was having a problem with one of my HttpGet Actions which was returning IQueryable<oneofmyclasses>. Using Fiddler2 to watch the request, I could see I was getting an internal server error (500), with no body text to explain why. I received no errors thrown in my Action.
Check 1: I verified that my Action was indeed getting to the return collection.AsQueryable(); line with no errors. It was
Check 2: I verified that my data was serializing to JSON with no errors using this code (g is my collection):
var json = new JsonMediaTypeFormatter();
json.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
ObjectContent<IEnumerable<Model.MenuGroup>> responseContent = new ObjectContent<IEnumerable<Model.MenuGroup>>(g, json);
MemoryStream ms = new MemoryStream();
responseContent.CopyToAsync(ms).Wait();
ms.Position = 0;
var sr = new StreamReader(ms);
var str = sr.ReadToEnd();
This also worked. I also tested it using XML formatter even though I was pretty sure it only ever used JSON (can't be too careful).
Check 3: Enabled .Net Framework debugging. This time when the error occured (in HttpApplication.cs) VS 2012 caught it.
My error:
Despite having marked the property with these attributes,
[XmlIgnore]
[IgnoreDataMember]
[JsonIgnore]
the .Net Source was calling a get on one of my properties. The catch, it was a write-only property. I simply added
get { return null; }
and the problem was solved.
I probably should have just done Check 3 first, but my previous experience with this error has shown it to usually be an error trying to serialize my objects, which was why I had a bit of a head scratcher when they did serialize properly and the error persisted.
How I solved it:
Enabled .Net Framework debugging. Tools -> Options -> Debugging -> Check 'Enable .NET Framework source stepping'
This time when the error occured (in HttpApplication.cs) VS 2012 caught it.

Strange LINQ to SQL behaviour (BUG?)

We have this very strange issue on LINQ to SQL Code.
Consider this code snippet :
var wissen = db.Table.Where(f => f.Name == somevalue);
db.Table.DeleteAllOnSubmit(wissen);
db.SubmitChanges();
This works as expected on our dev servers, but when we are deploying this to our production server it doesn't give any errors but it doesn't delete anything neither altough it should.
When we replace this code with this :
db.ExecuteCommand("DELETE FROM Table WHERE Name = {0}", somevalue);
thing work just fine.
The workaround works just fine, but we would be happy to know what exactly goes wrong.
Looking forward to your comments :)
Dieter
Have you tried to do a SQL Profiler trace on the production machine to find out which SQL is being emitted?
This should help you troubleshoot the issue.
Is db a System.Data.Linq.DataContext? If not, try using one. If it is, call db.Log = Console.Out after instantiating, and it will send all the generated SQL to the Visual Studio output console. This should show what is going wrong.
If you can't run VS on the server, log output to a text file:
StreamWriter sw = new StreamWriter(pathToLogFile);
db.Log = sw;
// do your queries here
sw.Flush();

Resources