In an SSMS add-in, the following code will toggle the fontsize of the text editor window between 10 and 22:
Properties props_texteditor = _addInInstance.DTE.Properties["FontsAndColors", "TextEditor"];
Property propFontSize = props_texteditor.Item(3); //"FontSize"
propFontSize.Value = ((Int16)propFontSize.Value == 10 ? 22 : 10);
Not particularly useful, but it demonstrates that my add-in can set an SSMS Tools/Options property, in this case using the category/page names "FontsAndColors", "TextEditor".
What I actually want my add-in to do is set the scripting option "Include IF NOT EXISTS clause" to true or false, but I can't find any documentation on it. Anyone know how to do it?
Have a look at SSMSBoost add-in, that I develop. I have implemented custom scripting options there.
If you want to experiment yourself, have a look at these objects:
Microsoft.SqlServer.Management.UserSettings.ScriptingOptions
Microsoft.SqlServer.Management.Smo.Scripter
Related
When I've used Settings Designer before, I've been able to browse to find non-standard Types (e.g. uncommon enums etc) to use in my Settings via a "Browse" button at the bottom of the drop down under the "Type" column. I'm developing a WPF desktop application for .net Core and there is no Browse option as pictured below:
I did go into the code behind (Settings.Designer.cs.) and edit the code manually, but on saving, this just reverted to string. I'm guessing this may have something to do with settings also having an element in App.config and I notice it has a "serialiseAs" tag - didn't know what to put here. Exmaple of the code behind settings and App.config:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string UiTheme {
get {
return ((string)(this["UiTheme"]));
}
set {
this["UiTheme"] = value;
}
}
<userSettings>
<GameBoxer.WPF.Properties.Settings>
<setting name="UiTheme" serializeAs="String">
<value />
</setting>
</GameBoxer.WPF.Properties.Settings>
</userSettings>
Does anyone know how to bring back the 'Browse'?? Or, how to correctly do it in code?
I'm using Visual Studio 2022 Community
Thanks
UPDATE: So, I learn that this is "By Design" in VS2022 according to MS here. It's still present in VS2019! But they've taken it out of VS2022 and I can't figure how to do it in code. MS, you're one of my faves out the bunch, but sometimes, you're as mad as a box of frogs. unfortunately that link doesn't provide the poster with any alternatives other than "that's not a bug." Not very helpful, really.
As mentioned in the link you provided, this change was by design due to .NET Core and while I very strongly disagree with their stance on this - I'm assuming this was done because it could be quite fiddly to get your own types to work as expected, especially for new users.
One simple workaround if your custom data has several values, you can use string and simply write your own little parser using delimiters such as ;. You could also use StringCollection to achieve the same result.
Inconvenient, yes. But a simple solution nonetheless.
I sincerely hope Microsoft changes their stance on this and looks at reimplementing this as it worked remarkably well once you figured out the procedure to get it to serialize properly.
Edit:
Figured I might as well provide an example;
// Storing the Settings
// Parameter: Struct { Location(Point), Size(Point), Margin(Thickness) }
var settingString = $"{e.Location.X};{e.Location.Y};{e.Size.X};{e.Size.Y};{e.Margin.Left};{e.Margin.Top};{e.Margin.Right};{e.Margin.Bottom}";
Properties.Settings.Default.MySetting = settingString;
Properties.Settings.Default.Save();
// Parsing the Saved Setting
var settingString = Properties.Settings.Default.MySetting;
if (!String.IsNullOrWhiteSpace(settingString))
{
List<string> splitStrings = settingString.Split(';', StringSplitOptions.RemoveEmptyEntries).ToList();
List<double> parsedValues = new List<double>();
splitStrings.ForEach(x => parsedValues.Add(double.Parse(x)));
var location = new Point(parsedValues[0], parsedValues[1]);
var size = new Point(parsedValues[2], parsedValues[3]);
var margin = new Thickness(parsedValues[4], parsedValues[5], parsedValues[6], parsedValues[7]);
}
There's probably better ways of doing this, but I find this to be a very simple workaround and has worked great thus far.
I created some reports in Visual Studio 2015 with all the latest updates. However, when I try to deploy the reports I get this message:
The definition of this report is not valid or supported by this version of Reporting Services.
11:40:28 Error
The report definition may have been created with a later version of Reporting Services, or contain content that is not
11:40:28 Error
well-formed or not valid based on Reporting Services schemas. Details: The report definition has an invalid target
11:40:28 Error
namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.
The first lines of the .rdl file are set up like this:
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df"
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
Can I change the schema definition? If so, to what? I tried just changing 2016 to 2014 or 2012, but neither worked.
Is there a place I can go to see valid definitions?
I actually ran into a similar problem where a change I needed to make resulted in an "Undocumented Error/Invalid RDL Structure" error in 2016, so I edited the RDL file so I could open it in an earlier version and make my changes. Not too hard, but you need to make a couple of tag edits.
For new reports you should probably just use an older version, but for existing reports you can do this: (I reverted to 2008)
Change the Report tag:
Remove MustUnderstand="df"
Change the xmlns value to "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
Delete the xmlns:df attribute.
Delete the entire "ReportParametersLayout" block.
Delete the "df" tag and its content.
Delete the "ReportSections" and "ReportSection" opening and closing tags (not the content).
Actually wrote some superhackish code to do this as part of a blog post, but the manual edit is simple enough.
The settings below should be set to your sepecific version of SSRS, and then take the RDL from the \bin directory
Or, after updating the TargetServerVersion, simply use right click | deploy from the rdl.
The accepted answer is significantly more difficult/prone to error/unlikely to work across multiple versions of ssrs, and needs to be applied each time you change the rdl.
I had the same issue when switching to VS2017 and installed Report Designer Version 14.2.
For me only 3 steps needed to fix the issue.
1: Set Change the xmlns to "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
2: Remove ReportSections" and "ReportSection" (Only Tags).
3: Remove report ReportParametersLayout section.
The only thing you need to memorize is to point xmlns to 2008/01
Other 2 steps can be seen in the error message after you change to 2008/01 and try to run the report.
If you are having trouble in a Visual Studo 2017 C# desktop application with LocalReport (RDLC), please see this answer:
https://stackoverflow.com/a/45149488/6732525
I recently ran into this issue as well. I found that I only needed to change two items in the .rdl file in question.
Change FROM:
Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
TO:
Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"
Unlike other responses, I needed 2010 instead of 2008. I would check an .rdl file that you have already deployed.
Remove the "ReportParametersLayout" block.
Note: If I removed ReportSections block, it did not work as others have noted.
I ran in to same problem and this is how I solved it,
Set the "TargetServerVersion" property on report project properties to be your old version of reporting server.
Build the project.
Get the report in the bin folder and deploy to the old reporting server.
Your source reports format and namespace will be updated to latest version. But bin folder reports will be build to be compatible with targeted reporting server version.
I have automated this task.
create a form with a textbox named "TextBoxFile" and a button.
In the code of the click button:
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(TextBoxFile.Text)
Dim root = xmlDoc.DocumentElement
For Each elel As XmlNode In root.ChildNodes
Debug.WriteLine(elel.Name & " " & elel.NodeType)
Next
If root.Attributes()("xmlns").Value <> "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" Then
root.Attributes()("xmlns").Value = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
End If
Dim nsmgr = New XmlNamespaceManager(xmlDoc.NameTable)
nsmgr.AddNamespace("bk", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition")
Dim autoRefreshElements = root.GetElementsByTagName("AutoRefresh")
While autoRefreshElements.Count > 0
root.RemoveChild(autoRefreshElements(0))
End While
Dim ReportParametersLayout = root.GetElementsByTagName("ReportParametersLayout")
While ReportParametersLayout.Count > 0
root.RemoveChild(ReportParametersLayout(0))
End While
Dim ReportSections = root.GetElementsByTagName("ReportSections")
If ReportSections.Count > 0 Then
' Move content of ReportSections just below the block.
Dim ReportSection = ReportSections(0).ChildNodes()
' First, copy the elements after
Dim precedent = ReportSections(0)
For Each child As XmlNode In ReportSection(0).ChildNodes
Dim clone = child.Clone
root.InsertAfter(clone, precedent)
precedent = clone
Next
' After deleting the existing block
While ReportSections.Count > 0
root.RemoveChild(ReportSections(0))
End While
End If
xmlDoc.Save(TextBoxFile.Text)
MsgBox("Ok")
The most simple and straight forward solution. I would suggest you to find Microsoft.ReportingServices.ReportViewerControl.WebForms in Manage NuGet Packages of the current project and update this dll version to latest version.
Navigate from VS menu: Tools > NuGet Package Manager > Manage NuGet Packages for Solution
Login through the local admin account and correct computer objects by deleting and creating those computer objects.
I am developing an windows application in F#. In the application I have to show the TextBox mode in Password Format. What is the code for using the password mode of TextBox in F#?
I have applied the following code:
let txtpwd = new TextBox(Top = 70, Left = 120)
From the above code the textbox is displaying. No problem. I have applied following code for password mode:
txtpwd.PasswordChar
The above code is not working properly.
You should set desired properties upon initialization of your control, for example:
txtpwd.Text <- "" // Set to no text
txtpwd.PasswordChar <-'*' // The password character is an asterisk
txtpwd.MaxLength <- 14 // The control will allow no more than 14 characters
Better yet, set the properties in your call to the constructor. One of the cool things about F# is that you can set properties in the call that you wouldn't normally be able to set in the constructor. Like this:
let txtpwd = new TextBox(Top = 70, Left = 120, Text = "", PasswordChar = '*',MaxLength = 14, Multiline = true)
This is basically equivalent to what Gene posted but, as far as I know, it's a little more idiomatic in F#.
If you check this page under the topic "Assigning Values To Properties At Initialization" (sorry can't post a direct link) although the page is discussing F# code, it holds for other .Net code as well.
This must be something very simple, I just don't see it (and can not find the answer :(
I am trying to learn DevExpress controls and have read that eXpress Persistent Objects is recommended for O/R mapping.
1) I have an existing SQL Server Compact 4.0 database for which I generated ORM
2) I have a Winform with XtraGrid.GridControl gridControl1
3) In Form_Load event I have this code:
XPCollection cName = new XPCollection(typeof(WindowsFormsApplication1.DUzskv1r6.XPO_TableName));
int c = cName.Count; //didn't help...
cName.DisplayableProperties = "Name;Nr"; //choose columns to display
gridControl1.MainView.PopulateColumns();
gridControl1.DataSource = cName;
I have read that it using "delayed loading" - loading when it is necessary (http://documentation.devexpress.com/#XPO/clsDevExpressXpoXPCollectiontopic), but reading XPcollections record Count didn't do the trick as it was suggested.
As a result I get an empty gridControl1 with columns "Name" and "Nr".
Please help - what am I missing?
I think the issue is somewhere in your datalayer initialization.
You use XPCollection with default session, maybe you forgot to initialize it.
The best way is to specify the session is in the XPCollection contractor.
Today I'm playing with localization. I have a winforms app where I've set localizable to true on my screen, then I went and converted all the text to spanish as best as I could. So now I have my screen.resx and my screen.es.resx and everything looks good/bueno. How do I now run my app and have the spanish version come up? I tried going into regional and language options and setting my 'standards and formats' option to spanish. Now my dates are in spanish which is good, but the text on my app is still the english version. How do I get this thing to load with my screen.es.resx?
Did you set your applications Culture/UI Culture to Spanish?
In following code, en-US will be replaced by your UI culture and it will use appropriate resx file depending on the way you have them set up
HTH
System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("en-US", false);
System.Threading.Thread.CurrentThread.CurrentUICulture = myCI;
System.Threading.Thread.CurrentThread.CurrentCulture = myCI;
You control which language resource that are used by setting the CurrentUICulture of the current thread. You will most likely also want to set the CurrentCulture (that controls number and date formats and such) (C# code):
// the following using statements must be present
// using System.Threading;
// using System.Globalization;
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("es-ES");
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;
For a more detailed discussion on the difference between CurrentUICulture and CurrentCulture, there is a blog post by Michael Kaplan on the topic.