Showing posts with label generated. Show all posts
Showing posts with label generated. Show all posts

Wednesday, March 28, 2012

Property DefaultSchema is not available for Database [DatabaseName] in SSMS

I've been researching the notification message [Property DefaultSchema is not available for Database [DatabaseName]]. This message is generated when I try to create a new table object using SSMS. I am logging into the SQL Server using an NT Authenticated Login which is mapped to an Active Directory Resource Group. I have found the following information specific to Default Schema's in SQL Server 2005.

First, by design, you cannot assign a Default Schema to an NT Authenticate Login that is mapped to a Windows Group. This is noted in the CREATE USER (Transact SQL) BOL topic - http://msdn2.microsoft.com/en-us/library/ms173463.aspx

"DEFAULT_SCHEMA cannot be specified when you are creating a user mapped to a Windows group, a certificate, or an asymmetric key."

QUESTION: Are there any plans to remove, or modify the query used to derive the Default Schema which is generating the message notification from SSMS?

SELECT (select default_schema_name from sys.database_principals where name = user_name()) AS [DefaultSchema]

This is quite frustrating for me, as I have to reply to my developers - by design you will receive this message when you try to create a table through the table editor using SSMS. I have also been informed that this same error is raised through VSTS for Database Developers.

It is a hassle, but you don't just have to tell people that they will get that error and cannot do anything about it. You just need to tell them that they must now specify the schema whenever they try to create a table.|||You'll encounter this error when you try to use the GUI to create a table, are not sysadmin, and your access to the SQL Server 2005 database is from a Windows group.

Monday, March 12, 2012

programmaticaly save deployed report in ASP.NET 2.0

Hi

Does somebody knows how to save a remote report on the webserver when the report is generated in a report viewer, all programmaticaly behind the scenes?

So I can view the report later.

Thx

There various approaches to this. Personally I would present the user with some UI for selecting which report they wish to view and submit this to the server using a HTML form. On the server side, check if the requested report exists (depending on how often you wish to recreate the report), if yes then redirect the user to the report, if not then you will need to make a call to the ReportService.Render method requesting HTML as the output format, write the html file to the server and then redirect the user to the newly generated file.

Obviously there are other considerations such as data security, parameters etc.... to consider.

|||

Thx

I have found a solution for the problem by using the Render method as you suggested.
On my localhost it works fine. Only thing to check is if it works on the internet as well.

Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string deviceInfo;

deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>";

byte[] bytes = rptAfdruk.ServerReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);

string sPath = Server.MapPath("/timesheet");
FileStream fs = new FileStream(sPath + "/docs/" + sRegId + "/" + sName + ".pdf", FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();