Wednesday, July 31, 2013

Why the backgroundowrker cancel operation button dosent work ?

I misread your original - I think you probably had the original off a bit - that should likely be "if (!worker.CancellationPending)", right?




Reed Copsey, Jr. - http://reedcopsey.com - If a post answers your question, please click Mark As Answer on that post. If you find a post helpful, please click Vote as Helpful.


Dynamic SQL - creating a temp table with a name that includes a random number

Prajesh,


Thank you for your excellent help !!


Your explaination was very clear !!


Best wishes,


Tom




MisterT99


Looking to create average rating over daily, weekly, monthly, MTD, quarterly, QTD, yearly, and YTD

In all the 3 queries you need to modified as below. I am calculating only for Month and Year, others you can try it yourself.


Example:



SELECT 'Company-Avg Recommendation of Service Rating-ExistingPt' AS ID,
Month(SurveyStart) as SurveyStartMonth,
Year(SurveyStart) as SurveyStartYear
ROUND(AVG(CAST(s.SurveyQ9 AS float)),2) AS DataPoint
FROM [dbo].[SurveyTb] AS s
GROUP BY Month(SurveyStart),Year(SurveyStart)





Regards, RSingh



Looking to create average rating over daily, weekly, monthly, MTD, quarterly, QTD, yearly, and YTD

Thanks. This worked out as a good stepping stone. I appreciate the quick response!

OPC server

I download it, but I do not understand where is the code ?


it install something on my computer but i do not see any code..





OPC server

ok I was able to found the code..


but it has a error on it ...


finding monthly aggregates on OLTP

I have four different pages within a site. Each page has an ID. Every customer that visits the site has a unique ID. Every visit has a date and time column. Now I want to find the monthly average visits of a particular customer on a particular page. The query below gives the daily count of a particular customers page visit. Now I want the monthly average of the same.



SELECT date, pagetype, customerID, COUNT(customerID)as Number
FROM [dbo].[pageinfo] join [dbo].[customer]
on pageinfo.cid = customer.id
group by date, pagetype, customerID


finding monthly aggregates on OLTP

post the DDL as well


Thanks and Regards, Prajesh Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


Error: the database could not be exclusively locked to perform the operation in sql server 2008 ?

I am trying to rename the database but i am getting below exception while doing it-->


Error: the database could not be exclusively locked to perform the operation.(Microsoft Sql Server,Error 5030)


Thanks.


Error: the database could not be exclusively locked to perform the operation in sql server 2008 ?

Thats because someone else is accessing the database.. Put the database into single user mode the rename it.



USE [master];
GO
ALTER DATABASE foo SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
EXEC sp_renamedb N'foo', N'bar';



vt




Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker


Error: the database could not be exclusively locked to perform the operation in sql server 2008 ?

as mentioned earlier by both these users just wait for all the connections to go and then try- it will succed


or else if it is dev\Uat environment & you can kill the conenctions - make the changes (use this as last option)


i was just wondering if you are connected to the same DB? If yes change your context to master(means connect to master DB ) and then issue this command.




Sarabpreet Singh Anand


Blog , Personal website


This posting is provided , "AS IS" with no warranties, and confers no rights.


Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.


Error: the database could not be exclusively locked to perform the operation in sql server 2008 ?

you forgot a step: setting the db back to multi-user afterwards.

Set textblock text in a flipview in Metro App C#

Hi,


How can I set the text of a textblock which resides in a flipview, with value that I retrieved from the WCF service?


Here are some codes in the code-behind of ItemDetailPage:



protected async override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
// Allow saved page state to override the initial item to display
if (pageState != null && pageState.ContainsKey("SelectedItem"))
{
navigationParameter = pageState["SelectedItem"];
}

// TODO: Create an appropriate data model for your problem domain to replace the sample data
var item = SampleDataSource.GetItem((String)navigationParameter);
this.DefaultViewModel["Group"] = item.Group;
this.DefaultViewModel["Items"] = item.Group.Items;
this.flipView.SelectedItem = item;

VirtualMachineDetails vmDet = new VirtualMachineDetails();
var selectedVm = item.Title;
if (selectedVm != "")
{
vmDet.VmName = selectedVm.ToString();
var myFlipView = flipView as FlipView;
var container = myFlipView.ItemContainerGenerator.ContainerFromItem(myFlipView.SelectedItem);
var children = AllChildren(container);

var vmStateTxtBox = children.OfType<TextBlock>().First(x => x.Name.Equals("tbStatus"));

vmStateTxtBox.Text = await objService.GetVMStatusAsync(vmDet);
}
}


public List<Control> AllChildren(DependencyObject parent)
{
var list = new List<Control> { };
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
if (child is Control)
{
list.Add(child as Control);
}
list.AddRange(AllChildren(child));
}
return list;
}



I get an error at the following line:



VisualTreeHelper.GetChildrenCount(parent)

Here's the error:



Can anyone point where I went wrong with the coding?


I referred to Jerry Nixon's article about accessing named control in a XAML in order to access the textblock in my flipview:


http://blog.jerrynixon.com/2012/09/how-to-access-named-control-inside-xaml.html


Thanks.


Set textblock text in a flipview in Metro App C#

Did you try the first method Jerry suggested in his blog post?


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Printing a file

Is it possible to send a file directly to the print charm?


My app creates a PDF and stores it locally, I want the print dialog to come up immediately after the PDF has been generated.


If it is not possible in 8.0, will it be possible in 8.1?


SharePoint Global Navigation - Multi Level FlyOut's not functioning in IE10

Hi dbrost,


Based on your description, my suggestion is as the followings:


1. Press F12 to bring up the developer tools, and force the User Agent string to IE 8.


Tools->Change user agent string->Internet Explorer 8


2. Try follow line in Master page:

<meta http-equiv="X-UA-Compatible" content="IE=10; IE=9; IE=8; IE=7; IE=EDGE" />


Please inform me freely if you have any questions.

Thanks,




Qiao Wei

TechNet Community Support



Connection Pooling and connection leak

Could the following cause our application to leak connections?




using (var context = GetMyEntityConnection())

{

//Do Stuff

var myRecord = context.MyTable.Where(x=> x.id == 1).SingleOrDefault();

//Do more stuff

}

protected MyEntities GetMyEntityConnection()

{

var context = new MyEntities(GetPreparedConnection(FSWellKnownConnection.MyDB));

context.CommandTimeout = Constants.ENTITY_CONNECTION_TIMEOUT;

return context;

}

public virtual EntityConnection GetPreparedConnection(FSWellKnownConnection connection)

{

EntityConnection con = null;

try

{

con = new EntityConnection(GetConnectionString(connection));

con.Open();

using (var com = con.StoreConnection.CreateCommand())

{

com.CommandType = System.Data.CommandType.Text;

com.CommandText = "set arithabort on;";

com.ExecuteNonQuery();

}

}

catch

{

if (con != null)

{

con.Dispose();

con = null;

}

throw;

}

return con;

}

Connection Pooling and connection leak

Hi,


There is no way to know. GetPreparedConnection returns an open connection and we have no idea what you'll do with it.


Do you have a full pool issue ? If you use perfmon.exe to check those performance counters : http://msdn.microsoft.com/en-us/library/ms254503.aspx while running your app, it could give an idea about when it happens (i.e on which forms or pages).


Depending on your app, some relatively light code changes could allow to better track that (for exemple using the SqlConnection.Disposed or StateChanged events) by writing to the Debug window.


Once you fixed your issue, you'll likely have to open a new thread to see if your current pattern couldn't be improved (not sure how the returned connection is used, but basically it should be kept as local as possible and even if using a "reader" you do have an option to dispose the connection when the reader is "closed". Your main app code should get "data", not a connection that it will use to get at those data).




Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".


Connection Pooling and connection leak

Yes, we have a full pool issue.


When testing this today, we notice that every click that is made increases the open connections on SQL Server but doesn't close them. Eventually, the connections are closed after about 5+ minutes.


All of our data access methods use the above code to get or write data. We thought that using the "Using()" statement would close the connection. But perhaps the connection has to be made in the Using() statement and not call another method that returns the connection?


Help needed in bulk insert

DateTime field validation in Sharepoint

any help would be appreciated

DateTime field validation in Sharepoint

Hi Betta,


Do you use Visual Studio or only SharePoint Designer?


If you use Designer, you could use InfoPath too, it's really usefull in order to customize your forms.


DateTime field validation in Sharepoint

Hi thanks for ur response.. But I am not allowed to use InfoPath... I need to do this through designer.. Yes I can use visual studio too

Complete Visual Studio Workflow State Programatically on a Specific Date

Hi All,


I have a requirement where I need to complete the workflow on a specific date. The workflow I designed is for a vacation workflow and need to have the workflow status as complete on the day the employee's vacation day starts. Is there any activity or a workflow timer job that would run on a specific time to compare now date with the date stored in a variable and then put the workflow state in a complete or In Progress state. I would prefer not to use a SPTimerJob with this and would prefer something within the workflow foundation.


Thanks in advance.




what is the difference between Static cursor,Dynamic cursor and keyset cursor

Exactly what you want is here..


http://www.dotnet-tricks.com/Tutorial/sqlserver/RLID060512-SQL-Server-Different-Types-of-Cursors.html




Thanks and Regards, Prajesh Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


what is the difference between Static cursor,Dynamic cursor and keyset cursor

Hi shortly:



  • STATIC cursor: in the background creates a temporary table and fills it with the resultset of the select of the cursor. Then it fetches these static state of records from that temp table independently the original source of data.

  • DYNAMIC cursor: in every row fetch executes the base query again and again but returns only the corresponding row from the resultset

  • KEYSET cursor: stores only the primary keys in the backgound temporary table and in every row-fetch it queries the original data based on the current key




m@te


Problem in combobox

If nothing is selected inside the combobox, the selectedindex will be -1, that's by-design.


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Problem in combobox

Hello matt,


I am default selection is to 0.



this.cmbcusttype.SelectedIndex = 0;

So that is default selection. But my question is when i am click combobox for select item from combobox, And i am click out of the combobox, my output is same as fig 2.I can't understand what's happening in there.


Problem in combobox

ComboBoxes have different eventhandlers which mean different things.


Check this out


http://blogs.msdn.com/b/jaredpar/archive/2006/11/07/combobox-selecteditem-selectedvalue-selectedwhat.aspx




JP Cowboy Coders Unite!


Problem in combobox

Hello Jp,


thanks for your answer. But in my case i don't difference of selected index i m try that thing But the result is same.


Looking to create average rating over daily, weekly, monthly, MTD, quarterly, QTD, yearly, and YTD

In all the 3 queries you need to modified as below. I am calculating only for Month and Year, others you can try it yourself.


Example:



SELECT 'Company-Avg Recommendation of Service Rating-ExistingPt' AS ID,
Month(SurveyStart) as SurveyStartMonth,
Year(SurveyStart) as SurveyStartYear
ROUND(AVG(CAST(s.SurveyQ9 AS float)),2) AS DataPoint
FROM [dbo].[SurveyTb] AS s
GROUP BY Month(SurveyStart),Year(SurveyStart)





Regards, RSingh



Import SharePoint Solution Package to existing vs2010 project

Hello,


Yes, you can modify the site definition and add more items to it. (see steps 4 in link) when you open template in VS you will see all the related site contents in solution. See more ref from MSDN


http://msdn.microsoft.com/en-us/library/gg512104%28v=office.14%29.aspx


Hope it could help




Hemendra:Yesterday is just a memory,Tomorrow we may never see

Please remember to mark the replies as answers if they help and unmark them if they provide no help.


SharePoint Library Modal Pop-up for specific Content Type

Does your Excel Content type have a template attached to it? If not then the default behaviour of the New button becomes an upload window.


Don't forget that you're dealing with a document library in this case which is not the same as a list, they are similar in many ways but annoyingly different in others.


For a bit more information:


I hate linking to videos but this shows the process to create a new CT and then attach a template to it: http://www.youtube.com/watch?v=Jh-zIP_YBBw. Jump to 58 seconds in to see how to add a template to an existing Content Type.


This link covers some of the surrounding information but not how to attach a specific template to a Content Type. Worth a read for background knowledge: http://office.microsoft.com/en-gb/sharepoint-foundation-help/set-a-file-template-for-a-document-or-form-library-HA010377912.aspx


SharePoint Library Modal Pop-up for specific Content Type

The add document link at the bottom of the page always defaults to upload I think. I'm not sure if it's possible to change that to default to create a new one (without putting some JQuery to overwrite the action).


For creating the document this blog seems to do what you want: http://www.novolocus.com/2009/03/04/add-a-create-new-document-link-to-a-page/


In particular this is the javascript that runs to create a document based on a particular CT



createNewDocumentWithProgID('http:\u002f\u002fvm-moss2007\u002fMod Props\u002fForms\u002fMod Props\u002fModPropTemplate.xlsx', 'http:\u002f\u002fvm-moss2007\u002fMod Props', 'SharePoint.OpenDocuments', false)


Performance difference of inner-scoped variables and outer-scoped

Hi,


I would like to confirm whether my thinking is correct. With the following code block:



public SomeMethod()
{
MyClass myClass = null;
for (int i =0; i < 10; i++)
{
myClass = InstantiateMyClass();
myClass.DoSomething();
}
}



Has any performance/memory advantage over:



public SomeMethod()
{
for (int i =0; i < 10;i++)
{
MyClass myClass = InstantiateMyClass();
myClass.DoSomething();
}
}



In this case, myClass is not immutable. My Thinking is that they are not different because even though you are creating a new variable in the second code block, the first code block also creates the same new memory-space allocation but just re-points an existing variable declaration to a new memory allocation. I've been in conversation with some colleagues who believe that the first code block should be faster.


Anyway...just something to think about over coffee, but your input would be much appreciated.


Kind Regards


Mike



What is the difference between C# 2010 and 2012

I'm new to programming but I was started learning C# 2010 , is this good or bad , I mean do I must start learning C# 2012 or what


Mohamed Ahmed Database Administrator & Developer


What is the difference between C# 2010 and 2012

Hi,


if you're familiar with a former version of C# the step to the newest version is very small. Have a look at this blog post to become familiar with the new features.




Best Regards. When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer. This helps us build a healthy and positive community.


@Horizon_Net | Blog


What is the difference between C# 2010 and 2012

I believe you have the C# version confused with the Visual Studio version. The current version of C# is 5.0, here you'll get a nice run down of what's new and how it compares to 4.0 and previous versions. Basically the async and await operators are the biggest new additions to the language in version 5.

Performance difference of inner-scoped variables and outer-scoped

Hi,


there can be a difference between them depending on the further usage of your myClass variable. If you don't use this variable in further steps there's no problem to put it into the for-loop.


From an optimization point of view I would prefer the first one, because this variable must not be instantiated every time your loop goes a step further. From a readability point of view the second option would be better (R# would suggest to go for the second option). Anyway, that will give you, if any, just a small performance boost. There are other things you should more care about when looking for performance optimization.




Best Regards. When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer. This helps us build a healthy and positive community.


@Horizon_Net | Blog


Rewriting scalar function to table function

Hi,


I have just re-written a scalar fuction to a table fucntion, however there is a small problem. Within the scalar function, there is a section where the return value is set to null, this means that if no value gets assigned to it within function logic, it will return null. It is however proving problematic transferring thesame login to a table function since I cannot assign variables.


I need a way to check whereby if the select statement returns nothing from inline query, then simply return null. Is there a built in SLQ function similar to isnull that can do this ?


Rewriting scalar function to table function


if the select statement returns nothing from inline query, then simply return null.





In a TDF you would return nothing (= no row) instead.


Olaf Helper


Blog Xing

finding monthly aggregates on OLTP

I have four different pages within a site. Each page has an ID. Every customer that visits the site has a unique ID. Every visit has a date and time column. Now I want to find the monthly average visits of a particular customer on a particular page. The query below gives the daily count of a particular customers page visit. Now I want the monthly average of the same.



SELECT date, pagetype, customerID, COUNT(customerID)as Number
FROM [dbo].[pageinfo] join [dbo].[customer]
on pageinfo.cid = customer.id
group by date, pagetype, customerID


finding monthly aggregates on OLTP

post the DDL as well


Thanks and Regards, Prajesh Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


Problem in combobox

If nothing is selected inside the combobox, the selectedindex will be -1, that's by-design.


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Problem in combobox

Hello matt,


I am default selection is to 0.



this.cmbcusttype.SelectedIndex = 0;

So that is default selection. But my question is when i am click combobox for select item from combobox, And i am click out of the combobox, my output is same as fig 2.I can't understand what's happening in there.


Problem in combobox

ComboBoxes have different eventhandlers which mean different things.


Check this out


http://blogs.msdn.com/b/jaredpar/archive/2006/11/07/combobox-selecteditem-selectedvalue-selectedwhat.aspx




JP Cowboy Coders Unite!


Get a Max and Min using CountDistinct

Try this query,



SELECT Country,Topic,(SELECT Distinct Count(Question_Key)
FROM ExampleTable B WHERE B.Country=A.Country AND B.Topic=A.Topic) as CountDistinct,
MAX(Question_Key) MaxQuestion,
MIN(Question_Key) MinQuestion
FROM ExampleTable A
GROUP BY Country,Topic





Regards, RSingh


splistitem.Uniqueid

Hi,


There is a property for splistitem called Uniqueid, My question is can two different lists have items with the same Uniqueid?


Thanks,


Shravan


splistitem.Uniqueid

Since this property is a guid my assumption is it is unique within the entire farm and you won't have two lists with the same unique id. I don't know if you can assign a specific id.



Workflow Action Solution \ non Sandbox?

Can a Workflow Action be bundled with non Sandbox Solution?


I try to make it, and it nicely deployed and activated on site, action shows up in SPD, but it always cause error in workflow.


While when it is a sandbox solution everything works fine.


Tuesday, July 30, 2013

Reading data from a Dataset(*.csv) file and saving saving it to mysql database

first create the database and tables.to read a csv(comma seperated value )file see here:


http://social.msdn.microsoft.com/Forums/en-US/887e6153-fb24-4ea0-892b-596a43b6b8b3/recommended-way-to-read-csv-file-in-64bit-environment


read a csv file into datatable then insert into database table using simple inser querey or use bulk insert.



you can read the csv file using ado.net also. see here:


http://gyansangrah.com/ArticleContent.aspx?ID=reading_csv_files_in_ado_net


Reading data from a Dataset(*.csv) file and saving saving it to mysql database

thanks for your answer Mr sridhar rajan, the solution you provide is VB.Net solution, can you please provide some solution in C#.Net. thanks

How to refer a shared datatemplate

Hi,encoderuser


You can code like this in XAML:



<GridView ItemTemplate="{StaticResource dt}"></GridView>

Also,you can refer to this sample to know more about Gridview datatemplate:


http://code.msdn.microsoft.com/windowsapps/ListViewSimple-d5fc27dd


Best Wishes!


How to refer a shared datatemplate

Thanks! I must have had a typo or something. Tried this but didn't work.

JavaScript- Reference a Library












I am attempting to reference a document library in JavaScript. From what I have read, I should be able to open the library using the following code:



list = web.get_lists().getByTitle('Vacation NonTravel Requests');
var collListItems2 = list.getItems(SP.CamlQuery.createAllItemsQuery());

context
.load(collListItems2);
context
.executeQueryAsync(
function(){
alert
('success');
},
function(){alert('fail');}
);


The problem here is that I cannot get the list via this request- rather, I receive the error List 'Vacation NonTravel Requests' does not exist at site with URL .... I assume this is because I am not dealing with the spaces properly, but when I navigate to the library, the URL shows it with spaces. Regardless, I have tried replacing them with _x0020_ as SharePoint seems to do with some field names (replacing the double space with _x0020__x0020_, _x0020_x0020_, and _x0020x0020_, each with no success), and I have tried simply removing the spaces. I'm not sure what to try next, or even if this is actually the reason for my error message. Has anyone dealt with this before?


Just before this code, I have a similar query (on a list) that is working fine. I use collListItems2 here in case the issue has to do with the variable being in use, and I have created duplicates of both the context and the web variables for the same purpose.


EDIT: I have also tried replacing the spaces with %20, but still no luck






Unknown error trying to lock file

I am trying to test the functionality of my approval workflow. When I click on the document link in the email that is sent, the document opens but when I click 'Edit Document' I get the "Unknown error trying to lock file." I have have researched and tried a lot of things but none seem to work. Any ideas?


Lyndsey


Unknown error trying to lock file

Hello,


Which version of sharepoint your are using?


For your issue, just try belwo suggestion:


https://social.technet.microsoft.com/wiki/contents/articles/11155.unknown-error-trying-to-lock-file.aspx


Let us know your result




Hemendra:Yesterday is just a memory,Tomorrow we may never see

Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Unknown error trying to lock file

I am using SP Server 2010. I tried and I am still getting the error.


Lyndsey


Unknown error trying to lock file

Lyndsey,


What is your office and OS version?


If it is win XP/vista then try below hotfix:


http://darrellharvey.com/unknown-error-trying-to-lock-file/


http://wiki.uky.edu/sharepoint/Wiki%20Pages/Unknown%20Error%20Trying%20to%20Lock%20File.aspx


If still face the same issue then try to edit same doc in different OS machine.




Hemendra:Yesterday is just a memory,Tomorrow we may never see

Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Unknown error trying to lock file

My OS version is the 64 bit - operating on Win 7 Enterprise.



Tried the hotfix's, they didn't work. I am now getting an additional error. When I open up the document I can click "Edit Document" which gives me the "Unknown error trying to lock file." Now I can also click "Open this Task" and the task form pops up where I can select Approve, Reject, etc...If I click any of these options I get an error "Cannot update this task because upload has failed."



Also I don't have access to open the document on another OS machine.


Lyndsey


Unknown error trying to lock file

I have the same problem. The user is trying to open a Word document 2007 previously saved by a different user and it says "Unknown error trying to lock file". The user is on Windows 7, SP2010 and IE9.

Unknown error trying to lock file

It could be your IE9. Trying uninstalling it to an earlier version and seeing if that helps.

Unknown error trying to lock file

Try unistalling your IE9 to the earlier verion of IE and see if that is the issue.

Sorting filenames...please help!

Hi Wizend!


Yes, what I must accomplish is that the files with the "Main" as their 11th through 14th character show up at the top of the file listing in the File Explorer without renaming. In other words, it would be like a Sort but in DESC decending order so that the "M' From the "main' in the files is shown ahead of the files with "extr" in the same location within a file.


THe purpose is that I move the files to a particular directory and the files with the "main" in them must be moved first.


I hope this makes better sense. Thanks for your help!

Mike




Mike Kiser


Select multiple column into a single column

Try this

SELECT isnull(col1,'') + isnull(col2 ,'')+ isnull(col3,'') as newCol FROM Tablename





Satheesh


Select multiple column into a single column

If you use SQL Sever 2012, you can use the new CONCAT function:



select concat(col1,col2,col3) as newCol From SS2012DBTable


ScrollViewer keeps moving back

The ScrollViewer's default behavior is to bring the focused item into view. This will snap to the beginning of the item.


You can disable it for your ScrollViewer by setting http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.bringintoviewonfocuschange.aspx to false.


--Rob


Creating a matrix report style

Hi,


On what field the Row Group "capacidad" created? Can you post the screen shot of group properties? By chance it was created on IdTaller field?


Regards


Srini


Creating a matrix report style

Hi,


There is no need to have UniqueId. I tried same data in SSRS SQL 2008 R2, I got 100 and 80 groups. Can you please check the rows in Query Designer in SSRS on Dataset properties?


Srini


How can I debug a parameterized query?

Hi,


just some guessing, as there is no SQL and schema information.


You declare sParam3 as Date type but assigning a string:



cmd.Parameters.Add("sParam3", OracleDbType.Date).Value = sParam3;

You should convert the sParam3 to a Datetime or use a varchar2 parameter and a Oracle function like TO_DATE to convert it in the query.


For better breakpoint handling: Move the declaration of OracleCommand cmd outside the try catch block, then you can set a breakpoint in the catch block and the CommandText property and its Parameters collection is accessible.


Regards, Elmar


How can I debug a parameterized query?

As "Elmar Boye" suggested you should convert the sParam3 to datetime. Probably you should write your code as below



DateTime dt;
if (DateTime.TryParse(sParam3, out dt) == true)
{
cmd.Parameters.Add("sParam3", OracleDbType.Date).Value = dt;
}
else
{
cmd.Parameters.Add("sParam3", OracleDbType.Date).Value = DBNull.Value;
}





Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor


How can I debug a parameterized query?

ex.Message is not enough information. You need Message, StackTrace, InnerExceptions and possibly the other Fields of the Exception.


And the way to get them is ex.ToString()


Se here for more infor on proper exception handling:


http://www.codeproject.com/Articles/9538/Exception-Handling-Best-Practices-in-NET




Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.


How can I debug a parameterized query?

In visual studio you can set the break point and on the left of right click on the red dot... there are options like break on a condition or break on a hit count.

How can I debug a parameterized query?

In visual studio you can set the break point and on the left of right click on the red dot... there are options like break on a condition or break on a hit count.

He knows. The problem is he calls that code from a loop and only one of the last transfers fails. He can't break on the dozen others.



Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.


How can I debug a parameterized query?



<<<<<<<<<<<<<<<<Here is one weird way to pass information to an area you normally don't see but I've done it as a last resort and have found what I was looking for.

public OracleDataReader ExecuteParamReader(string sql, string sParam1, string sParam2, string sParam3)
{
<<<<<<<<<<<<<<<<<Do some variable in this scope
try
{
<<<<<<<<<<<<<<<<<<<,,In here set those out of scope variable with info...
OracleDataReader reader;
OracleCommand cmd = new OracleCommand(sql, conn);
cmd
.Parameters.Add("sParam1", OracleDbType.Varchar2).Value = sParam1;

When in your catch area If you don't see those variables in the Locals tab type the variable names in the Watch tab.

How to limit the number of threads in C#

Hello,


I think that limiting the amount of threads is quite problematic and while it might solve your problem temporarily it will hunt you in the long run when the application will need to scale so it's not really a solution.


It's really hard to tell you what to do without any details about the application such as the application environment, database infrastructure and the actual database you're working against.


I'm not sure what you're doing there but maybe a new connection should be created per session and not really per thread.






Regards,



Eyal Shilony


How to limit the number of threads in C#

Agreed, limiting the Thread Number is not a really good solution.


Actually to opposite approach might be better: consider packing as much work as possible into one Query isntead of splitting it over as many Queries as possible.


The basic rules for DB access from Code:

Do as few querries as possible, pack as much work into one Query as possible, while retrieving as little data as you need. Compared to your other code DB-access is very costly and splitting them up only increases the cost.


Could it be that you ran into a Timeout or OutOfMemory Exception while doing the work in one run?


The Command Timeout can be increased:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx


While a OOM is better solved by using paging (retrieving a smaller group at once, isntead all at once or all seperately) or reducing the number of Rows retreived:


http://blogs.iis.net/webtopics/archive/2009/05/22/troubleshooting-system-outofmemoryexceptions-in-asp-net.aspx


If this is only about not locking up the UI, use one Thread to do all the rerieval work in one go.


In any case we need a lot more details about what you are doing to give any specific advice.




Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.


Shrink Database

Hi ,


Any relevant answer for my question.


I understood that completed concept. I am planning rebuild all the indexes which having 80% of fragmentation.


In this case how to shrink the entire DB after rebuilt the index.


I requesting you to please don't post 100 of lines. Just tell me the correct procedure to shrinkDB.


How to write a cursor to compare the values of the rows and columns

What is the value you are trying to compare SampledDate or FurnaceID?


Try using recursive CTE than chosing cursor for this operation.


http://msdn.microsoft.com/en-us/library/ms186243(v=sql.105).aspx


https://www.simple-talk.com/sql/t-sql-programming/sql-server-cte-basics/




Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


Sorting filenames...please help!

Ooops, I just realized I got you completely wrong.


But, what do you mean with 'to be shown at the top of the folder'. Do you mean that the output of a directory read process should be rendered in that order? Or, do you wish to rename the files, so that they show up in that order in the File Explorer or other graphical representations?


wizend


Arithmetic overflow error converting numeric to data type numeric - SQL 2008

Msg 8115, Level 16, State 8, Line 178

Arithmetic overflow error converting numeric to data type numeric.

The statement has been terminated.



I have a report that calls the below mentioned SQL Function cusPovLevel_Revision. Above is the error I got back when running a set date range. After some investigating, I found the client to have a few patients with an annual income of 999999996.00. Obviously a data entry error. I have tried mofifying the function to account for this large number and cant seem to make it work right. Any help is appreciated.



USE [demo];
GO
/********************************************************************************************************
***** Object: UserDefinedFunction [dbo].[cusPovLevel_Revision] Script Date: 07/30/2013 11:05:18 *****
********************************************************************************************************/
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
ALTER FUNCTION dbo.cusPovLevel_Revision
(
@liIncome INT ,
@liFamilySize TINYINT ,
@lcSFEffectiveDte CHAR(8)
)
RETURNS INT
AS
BEGIN
DECLARE
@liBaseIncome NUMERIC(12 , 2) ,
@lcPayPovCode CHAR(3) ,
@liPayPovID INT ,
@lcFamilySize CHAR(3) ,
@liPctPov DECIMAL(8 , 3) ,
@lcCode VARCHAR(200) ,
@liMedListsId INT ,
@liRetVal INT ,
@lnCsrBaseIncome NUMERIC(12 , 2) ,
@lcCsrEffDte CHAR(8) ,
@lnRetValBaseIncome NUMERIC(12 , 2) ,
@lnIncome NUMERIC(12 , 2) ,
@lnCode NUMERIC(12 , 2) ,
@liSFScheduleID INT;
IF @liFamilySize > 15
BEGIN
SET @lcFamilySize = '15';
END
ELSE
BEGIN
SET @lcFamilySize = CAST(@liFamilySize AS VARCHAR);
END;
DECLARE @csrBaseIncome CURSOR;
SET @csrBaseIncome = CURSOR
FOR SELECT BaseIncome = CAST( description AS numeric( 12 , 2 )) ,
EffectiveDteString = LEFT( LTRIM( FunctionName ) , 8 )
FROM cusCRIMedLists
WHERE code = @lcFamilySize
AND tablename = 'baseincome'
AND FunctionName IS NOT NULL
ORDER BY EffectiveDteString DESC;
SET @lnRetValBaseIncome = -1.00;
OPEN @csrBaseIncome;
FETCH NEXT FROM @csrBaseIncome INTO @lnCsrBaseIncome , @lcCsrEffDte;
WHILE @@FETCH_STATUS = 0
BEGIN
IF @lcSFEffectiveDte >= @lcCsrEffDte
BEGIN
SET @lnRetValBaseIncome = @lnCsrBaseIncome;
BREAK;
END;
FETCH NEXT FROM @csrBaseIncome INTO @lnCsrBaseIncome , @lcCsrEffDte;
END;
CLOSE @csrBaseIncome;
DEALLOCATE @csrBaseIncome;
IF @lnRetValBaseIncome = -1.00
BEGIN
RETURN 0;
END;
ELSE
BEGIN
SET @liBaseIncome = @lnRetValBaseIncome;
SET @lnIncome = CAST(@liIncome AS NUMERIC(12 , 2));
SET @liPctPov = @liIncome / @liBaseIncome * 100;
DECLARE @CrsrVar CURSOR;
SET @CrsrVar = CURSOR
FOR SELECT Code ,
MedListsId
FROM cusCRIMedLists
WHERE TableName = 'SlidingFeeScheduleDtl'
AND JoinId IN(
SELECT MedListsId
FROM MedLists
WHERE tablename = 'SlidingFeeSchedule' AND Code = 'S'
)
ORDER BY CAST( Code AS INT );
OPEN @CrsrVar;
FETCH NEXT FROM @CrsrVar INTO @lcCode , @liMedListsId;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @liRetVal = @liMedListsId;
SET @lnCode = CAST(@lcCode AS NUMERIC(12 , 2));
IF @liPctPov <= @lnCode
BEGIN
BREAK
END;
FETCH NEXT FROM @CrsrVar INTO @lcCode , @liMedListsId;
END;
CLOSE @CrsrVar;
DEALLOCATE @CrsrVar;
DECLARE @liPctPovInt INT;
SET @liPctPovInt = ROUND(@liPctPov , 0);
RETURN ROUND( @liPctPovInt , 0);
END;
RETURN 0;
END;
GO


Arithmetic overflow error converting numeric to data type numeric - SQL 2008

Dont find an issue with this value, any other value could be an issue.



declare @test numeric(12,2)
set @test=999999996.00
select @test
set @test=cast(999999996.00 as numeric(12,2))
select @test





Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


Drill through report in Power View

Hello Friends,


Can we create a power view report by the following requirement,


Drill through report for geography wise top 10 re-sellers.?


If yes is the answer to my question,can please guide me how i can do that?


Drill through report in Power View

Yes you can. Please go through below link. this has very nice explanation. In case you stuck with anything please reply.


Thanks


http://office.microsoft.com/en-us/excel-help/add-drill-down-to-a-power-view-chart-or-matrix-HA103240725.aspx


Drill through report in Power View

Thanks for the quick response...


how can we filter for top 10 resellers in Power view?


( But in power pivot directly we have an option named as 'top 10' for filtering purpose)

Sorting filenames...please help!

Here is another possible solution:



static void Main(string[] args) {
string path = <yourFilePath>;
string pattern = "(?<=.{10})\\w{4}(?=.*)";

var result = File.ReadLines(path).OrderBy(x => Regex.Match(x, pattern).Value);

foreach (var item in result) {
Console.WriteLine(item);
}

Console.ReadKey();
}


wizend

DB turns offline when RESTORE

Hi!


Just that, when I execute a RESTORE command the database turns offline automatically... dont know why.


I'm using SSIS on SQL Server 2012, and the ETL package fails when executing that query...


Can anybody help me?


Thanks!


DB turns offline when RESTORE

Hello Menri,


For a restore an exclusive access for the process which started the restore is required. During the restore, no one can access the database, of course, therefore it looks like it is "offline", but in fact it is in recovery mode.




Olaf Helper


Blog Xing

Shrink Database

Hi,


I gone through the some of blogs/site.(http://www.sqlskills.com/blogs/paul/why-you-should-not-shrink-your-data-files/) that Shrinking Database a bad thing. Is it true?If yes what is the alternative.


Shrink Database

Hi ,


I understood.


If this is the case if i what to shrink the database, which the correct method.(Step by Step T-SQL)


Creating a matrix report style

Hi,


On what field the Row Group "capacidad" created? Can you post the screen shot of group properties? By chance it was created on IdTaller field?


Regards


Srini


Follow info on homepage

I would like to kwon if it is possible display this info on homepage and how??



thanks


Follow info on homepage

Hi,


This web part is Followed Counts web part, available in SharePoint 2013 My Site News Feeds.


If you want to show the same message in normal site like team site home page, I would suggest you to custom a web part, that retrieve the following count of current login user.


To retrieve this information, you can use SPSocialFollowingManager class, which provides methods for managing a user’s list of followed actors (users, documents, sites, and tags), more information:

http://msdn.microsoft.com/en-us/library/microsoft.office.server.social.spsocialfollowingmanager_members.aspx


Thanks,




Qiao Wei

TechNet Community Support



Follow info on homepage

There may be an easier solution than the other response. If the web part is visible on your news feed page, edit the page and go to the web part settings. Click "Export" and save the web part to your computer. Go back to your welcome page or whatever page you are trying to add the web part to, click "Add a web part", "Upload a web part", and upload the file you downloaded. It should now appear under "Imported Web Parts" and you can add it to your page.

IIS Clustering

What is the best method to cluster ASP.net web application on IIS 7.5, Please provide me a guide with best method.


System Support Engineer i-Context Content Convergence (Pvt) Ltd


Sorting filenames...please help!

Create a class that implements the IComparer interface and pass an instance of this class to the Sort method of the list or Array containing the filenames: http://codebetter.com/davidhayden/2005/03/06/implementing-icomparer-for-sorting-custom-objects/

Best Method to update FK from IDENTITY(1,1) PK table after insert

OUTPUT is the best way to capture IDENTITY insert values:


http://www.sqlusa.com/bestpractices2005/outputidentitycapture/





Kalman Toth Database & OLAP Architect sqlusa.com

New Book / Kindle: Pass SQL Exam 70-461 & Job Interview: Programming SQL Server 2012



Best Method to update FK from IDENTITY(1,1) PK table after insert

so do i insert the OUTPUT into a temp table and then update my Person table? The problem is i am not inserting the PersonSourceId or the SourceId into my Person table because those are stored in my PersonMapping table. All i am inserting is the persons name with some other misc. data.

Best Method to update FK from IDENTITY(1,1) PK table after insert

would it be bad programming, and hurt my DB in the long run, to add a temporary column in my person table so the PersonSystemId goes with my insert and then i can update my PersonMapping table and then drop the temporary column in the Person table?

Drilldown subreport visibility

Hi, I am not sure what you are trying to do with Sub-Report & drilldown is possible. I would probably do a drillthrough report instead. Maybe I could be wrong too. Could you please include some sample data for your parent & child reports to test the drilldown possibility or a work around.


Thanks............




Ione



Monday, July 29, 2013

adding a Convert.ToInt32 Method

I have my code that's part of a BDC Model I'm creating...



{
ABCDataContext context = GetDBContext();
var item = (from e in context.TPFStatus.AsEnumerable()

where e.Document_Number == id

select e).Single();
return item;

}

This would be fine if "Document_Number" was a int as well but its a string. I need to convert from a string to an int. How would I go about adding this to my script...



public static int ToInt32(
long value
)

I can't get anything I try to work.


adding a Convert.ToInt32 Method



{
ABCDataContext context = GetDBContext();
var item = (from e in Context.TPFStatus.AsEnumerable()
where e.Document_Number == id
select e.Document_Number).Single();
return item;
int value = 0;
if(item is int)
value = (int)item;
else
value = Convert.ToInt32(item.ToString());
}

Try this


adding a Convert.ToInt32 Method

Can't you simply cast Document_Number to an int, like so:



var item = (from e in context.TPFStatus.AsEnumerable()
where int.Parse(e.Document_Number) == id
select e).Single();







Hey, look! This system allows signatures of more than 60 cha


adding a Convert.ToInt32 Method

Disregard what I said earlier; LINQ to SQL will try to convert the 'where' expression to a SQL expression, but it does not have a mapping for the int.Parse method. Fernando's solution should work. However, if you are using LINQ to SQL, then according to this MSDN page using Convert.ToInteger should work too.


What framework are you using? LINQ to SQL, Entity Framework, something else? What error message are you getting? What have you tried yourself?




Hey, look! This system allows signatures of more than 60 cha


adding a Convert.ToInt32 Method

This works well. But what if the field is a DateTime being converted to a string?


This same formula doesn't seem to work.


adding a Convert.ToInt32 Method

Can you post your code? Also, what is the error message you are getting?



Hey, look! This system allows signatures of more than 60 cha


adding a Convert.ToInt32 Method

Yes, please post a sample of the query you have tried because it matters if the data is coming from the database or data being sent to the server.


Fernando (MCSD)



If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Don't show field used in query

I have a query that's basically like this:


SELECT DISTINCT Column1, Column2, Column3, Column4


FROM TableName


Column4 is just an id field. I need Column4 to get the correct number of records, but I do want Column4 to appear in the results. Is there a way to do that?


tod


Don't show field used in query


SELECT Column1, Column2, Column3
FROM TableName
GROUP BY Column1, Column2, Column3, Column4




Tom

optimize the query

Why do you GROUP BY when you don't use any aggregation? Would a simple DISTINCT perform better?




Olaf Helper


Blog Xing




optimize the query

As I said, try having an index by (string, text, code). That would apply to both tables.




AMB


Some guidelines for posting questions...


optimize the query

Can't apply Index on the field Text where the datatype on it has varchar(2048)

optimize the query

Correct, the number of total bytes in the key can't be more than 900 if I recall well, so your only choice will be to let SQL Server do the sorting.


May be using the HASBYTES of those values. Check BOL fr more info about this function.




AMB


Some guidelines for posting questions...




optimize the query

Joining on string columns is not so good in SQL server, try to change the design (if possible) and make join on INT columns


Thanks and Regards, Prajesh Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


optimize the query

By Using HASBYTES, doe it allow me to create INDEX on that field?

optimize the query

Hi SQL_Gun,



Database Engine does not consider nonkey columns when calculating the number of index key columns or the total size of the index key columns, please try to create a nonclustered index on string, code columns and includes text column:



create nonclustered index IndexName on TableName(string, code)
INCLUDE ([text])

For more detail information, you can refer to the following link:



Maximum Size of Index Keys

http://msdn.microsoft.com/en-us/library/ms191241(v=sql.105).aspx





Allen Li

TechNet Community Support



optimize the query

Can you post the data/index DDL?


Why don't you use INT/BIGINT surrogate PRIMARY KEYs?


JOINing millions of records(rows) on text columns will result in a performance hit.


Optimization article:


http://www.sqlusa.com/articles/query-optimization/




Kalman Toth Database & OLAP Architect sqlusa.com

New Book / Kindle: Pass SQL Exam 70-461 & Job Interview: Programming SQL Server 2012



Development using Timers

Call method2 from the timer event.

Don't show field used in query

I have a query that's basically like this:


SELECT DISTINCT Column1, Column2, Column3, Column4


FROM TableName


Column4 is just an id field. I need Column4 to get the correct number of records, but I do want Column4 to appear in the results. Is there a way to do that?


tod


Don't show field used in query


SELECT Column1, Column2, Column3
FROM TableName
GROUP BY Column1, Column2, Column3, Column4




Tom

Sql Sever Convert rows to Columns for multiple tables

You need to pivot 2 columns, so I would try this:




DECLARE @MaxCount INT;
DECLARE @MaxCount1 INT;

SELECT @MaxCount = max(cnt)
FROM (
SELECT S.Id
,count(A.IPAddress) AS cnt
FROM dbo.D2D S INNER JOIN dbo.D2D_IPAddress A on S.Id = A.D2D_ID
GROUP BY S.Id
) X;

SELECT @MaxCount1 = max(cnt1)
FROM (
SELECT S.Id
,count(B.WWN) AS cnt1
FROM dbo.D2D S INNER JOIN dbo.D2D_WWN B on S.Id = B.D2D_ID
GROUP BY S.Id
) X1



DECLARE @SQL NVARCHAR(max), @Col1 nvarchar(max), @Col2 nvarchar(max),
,@i INT;

SET @i = 0;

WHILE @i < @MaxCount
BEGIN
SET @i = @i + 1;
SET @Col1 = COALESCE(@Col1 + ', ', '') +
'MAX(CASE WHEN Rn1 = ' + cast(@i AS NVARCHAR(10)) +
' THEN IPAddress END) AS IPAddress' + cast(@i AS NVARCHAR(10));
END

SET @i = 0;

WHILE @i < @MaxCount1
BEGIN
SET @i = @i + 1;
SET @Col2 = COALESCE(@Col2 + ', ', '') +
MAX(CASE WHEN Rn2 = ' + cast(@i AS NVARCHAR(10)) +
' THEN sno END) AS sno' + cast(@i AS NVARCHAR(10));

END

SET @SQL = N';WITH CTE AS (
SELECT S.ID, A.IPAddress, row_number() OVER (PARTITION BY S.ID ORDER BY A.IPAddress) AS Rn1

FROM dbo.D2D S INNER JOIN dbo.D2D_IPAddress A on S.Id = A.D2D_ID
), cte2 AS (
SELECT S.ID, B.WWn as Sno, ROW_NUMBER() over (partition by S.ID order by B.wwn) as Rn2
from dbo.D2D S INNER JOIN dbo.D2D_WWN B on S.Id = B.D2D_ID), cte3 AS (

SELECT COALESCE(A.ID, B.ID) as ID, A.IPAddress, A.Rn1,
B.sno, B.Rn2 from cte A FULL JOIN cte2 B ON A.ID = B.ID
AND A.Rn1 = B.RN2)

select ID, ' + Col1 + ', ' + col2 + ' FROM cte3
GROUP BY ID';

PRINT @SQL;

EXECUTE (@SQL);



The above is from the top of my head (since you didn't provide the test data) so you may need to do minor adjustments.




For every expert, there is an equal and opposite expert. - Becker's Law





My blog




My TechNet articles



How to write file chunk by chunk in WinRT?

I am trying to write buffer data into a file. I receive buffer data in a callback function continuously. I need to read the buffer and save it in a file as it is received. This will be repeated till i get complete file,i get data chunk of 4k in size. But below code either throws an exception or output file is corrupted. Please let me know how to do this in winRT.


Here is the code snippet.



StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync(strFileName, Windows.Storage.CreationCollisionOption.ReplaceExisting);
public async void Receive(byte[] buffer)
{
using
(var ostream = await file.OpenStreamForWriteAsync())
{
await ostream
.WriteAsync(buffer, 0, buffer.Length);
}
}

How to write file chunk by chunk in WinRT?

I'm confused.


1) What exception are you getting?


2) Why are you doing it this way?




Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


How to get Facebook redirect URL value.

Hi,


I'm working with windows store and windows phone 8 apps. I need Facebook lo-gin in my both applications. This process already done in web application its working fine when user successfully login with Facebook i have post method in my Facebook redirect URL page, this method doing process of user registration and return a user-id. Now i need to get this value from my windows store app and windows phone app. i'm using webauthenticationBroker in windows store application. Any one can help me?


Installing SSRS Web access

Hi newyorkfonzie,


Please refer to the following articles:

Report Server Web Service: http://technet.microsoft.com/en-us/library/ms152787.aspx

Report Server Web Service Methods: http://technet.microsoft.com/en-us/library/ms155071.aspx


Best Regards,




Elvis Long

TechNet Community Support



Installing SSRS Web access


To me this would be setting up the web server that the company would access reports on



Hello,


Which version of SSRS are you going to use? If its 2008 or higher, then you don't need a "web server" = IIS, because SSRS uses it's own HTTP.SYS to host the web gui "Report Manager" and the SSRS web service (SOAP).




Olaf Helper


Blog Xing

Installing SSRS Web access

Then just install SSRS, then you have all you need.


Olaf Helper


Blog Xing

update listItem file

Hi,


I have an issue with listItem file update ?


I have to update file attached to listItem. But sometimes a new file is created with the default contenttype in the documentset.


Here the code i use.



using (SPSite site = new SPSite(missionOrder.Web.Site.ID))
using (SPWeb web = site.OpenWeb(missionOrder.Web.ID))
{
bool allowUnsafeUpdate = web.AllowUnsafeUpdates;
bool parserEnabled = web.ParserEnabled;

try
{
web.AllowUnsafeUpdates = true;
web.ParserEnabled = false;
web.Update();

SPListItem item = web.Lists[missionOrder.ParentList.ID].GetItemById(missionOrder.ID);

item.File.SaveBinary(docmStream);
item.File.Update();

//fix for eventReceiver
int nbrOftry = 0;
item = web.Lists[missionOrder.ParentList.ID].GetItemById(missionOrder.ID);

while (item.File.ParentFolder.Name.Equals("Technique") == false || nbrOftry == 3)
{
System.Threading.Thread.Sleep(1000);
item = web.Lists[missionOrder.ParentList.ID].GetItemById(missionOrder.ID);
nbrOftry++;
}
//updating metadata and ContentType
SPContentType missionOrderCT = missionOrder.ParentList.ContentTypes["MissionOrder"];

item["ProjIDAffaire"] = affaireID;
item["MissionOrderID"] = missionID;
item["ContentTypeId"] = missionOrderCT.Id.ToString();
item["SynchroVersNomade"] = "True";
item.UpdateOverwriteVersion();

item = web.Lists[missionOrder.ParentList.ID].GetItemById(missionOrder.ID);

//Delete old item version.
try
{
SPListItemVersionCollection coll = item.Versions;

for (int i = 0; i < item.Versions.Count; i++)
{
if (!coll[1].IsCurrentVersion)
coll[1].Delete();
}
}
catch { }


web.ParserEnabled = parserEnabled;
web.AllowUnsafeUpdates = allowUnsafeUpdate;
web.Update();
}
catch (Exception)
{
web.ParserEnabled = parserEnabled;
web.AllowUnsafeUpdates = allowUnsafeUpdate;
web.Update();
}
}



Regards,


J.D.


Request for the permission of type 'System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

hello,


Am trying to find user's ipadress using below code,



IPHostEntry host;
string localip = "";
host = Dns.GetHostEntry(Dns.GetHostName());

foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localip = ip.ToString() + "-";
}
}

but am getting the below exception.



Request for the permission of type 'System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed



so i thought it must be the permission issue so i gave full trust level from web.config file. But still it showing the error. can any one tell me how to resolve this issue.


Request for the permission of type 'System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

Hi ghouse_silver,


Based on your description. I understand that you want to find user’s IP address using code, but the program throws an exception.


My suggestion is as the followings:



  1. Implement a custom CAS policy for your web application.

  2. Require strongly naming for the DLL.


Here is a similar case for you to take a look:


http://social.technet.microsoft.com/Forums/sharepoint/en-US/c4779b22-6d7a-43a9-913a-97d2c0d97493/sharepoint-security-configurations


Using custom CAS policy files in SharePoint 2010:


http://www.insidesharepoint.net/post/2011/09/04/Using-custom-CAS-policy-files-in-SharePoint-2010.aspx


Please inform me freely if you have any questions.

Thanks,




Qiao Wei

TechNet Community Support



What's the side effect disable RBS in SharePoint 2010?

RBS is supported with SQL 2012 clustering. You can also use RBS wtih SQL 2012's AlwaysOn Availability Groups.


If you enabled RBS you did so because you expected to have many large binary files. May I ask why you want to now disable RBS?





What's the side effect disable RBS in SharePoint 2010?

Thank you, If I do SQL 2012 clustering. I choose disable RBS before connect SQL 2012 clustering or not.?

What's the side effect disable RBS in SharePoint 2010?

Sorry, will you please clarify your current configuration and what you would like to do?


Are you using RBS now? Are you looking to move database servers?





SPFieldLookupValue does not update my list

Hi guys,


I'm trying to update my list programmaticaly with client object model.


this list contains a lookupfield, I'm using this code,



ListItem my = list.AddItem(new ListItemCreationInformation());

my["Title"] = "Test";
my["NAME"] = "Name";

SPFieldLookupValue spv;
spv = new SPFieldLookupValue(3,"Type");
my["TYPE"] = spv;

my.Update();
ctx.Load(my);
ctx.ExecuteQuery();

I have no error but when I refresh my list I have a new line with my new value, but the TYPE field is always empty....


any ideas?


thanks!


C# Public Override Method

May be you can use a Boolean member to decide whether or not to show EEID. For example, in below code, one can set CanShowEEID to display or not display EEID.



public class Person
{
int eeid;
public int EEID
{
get { return eeid; }
set { eeid = value; }
}

string firstname;
public string Firstname
{
get { return firstname; }
set { firstname = value; }
}

string lastname;
public string Lastname
{
get { return lastname; }
set { lastname = value; }
}

public bool CanShowEEID { get; set; }

public override string ToString()
{
string result = Firstname + " " + Lastname;
result = CanShowEED ? EEID + " " + result : result;
return result;
}
}



I hope this helps.


Please mark this post as answer if it solved your problem. Happy Programming!


Sql Sever Convert rows to Columns for multiple tables

The architecture of the database is very bad. You should work with a BIGINT column for IP and not String type!


If you post DDL+DML i will read the question by the way :-)




signature


Windows Store app - how to make HttpClient POST request

I want to make a POST request similar to this example:



POST /accesstoken.srf HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: https://login.live.com
Content-Length: 211

grant_type=client_credentials&client_id=ms-app%3a%2f%2fS-1-15-2-2972962901-2322836549-3722629029-1345238579-3987825745-2155616079-650196962&client_secret=Vex8L9WOFZuj95euaLrvSH7XyoDhLJc7&scope=notify.windows.com



THIS IS THE CODE I AM TRYING:




uri theUri = new System.Uri("https://login.live.com");


HttpRequestMessage re = new HttpRequestMessage();


HttpClient client = new HttpClient();

client.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Host = theUri.Host;


var body = String.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=notify.windows.com", MyCredentials, MyCredentials2);
HttpContent cont = new HttpContent();
StringContent theContent = new StringContent(body);
HttpResponseMessage aResponse = await client.PostAsync(new Uri("https://login.live.com/accesstoken.srf"),theContent);




When i run this i get an error saying bad request. I believe i a m doing this wrong since i am new at it.


What is the correct way to write this POST request?