Friday, February 28, 2014

Strange problem with case statement

I got into an issue with the below statement. I don’t understand why it is not working as expected. Structure for table is below

Months Cash

1 4.13

2 46.02

3 46.02

4 5.31

5 5.31

6 51.33

7 393.53

8 393.53

9 46.02

10 51.33

11 57.82

12 32.45

13 0

14 0

15 0

select ‘Total’ as Months

,Cast(max(case when Cash = ’4.13′ then Cash end) as varchar(20)) [1]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [2]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [3]

,Cast(max(case when Cash = ’5.31′ then Cash end) as varchar(20)) [4]

,Cast(max(case when Cash = ’5.31′ then Cash end) as varchar(20)) [5]

,Cast(max(case when Cash = ’51.33′ then Cash end) as varchar(20)) [6]

,Cast(max(case when Cash = ’393.53′ then Cash end) as varchar(20)) [7]

,Cast(max(case when Cash = ’393.53′ then Cash end) as varchar(20)) [8]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [9]

,Cast(max(case when Cash = ’51.33′ then Cash end) as varchar(20)) [10]

,Cast(max(case when Cash = ’57.82′ then Cash end) as varchar(20)) [11]

,Cast(max(case when Cash = ’32.45′ then Cash end) as varchar(20)) [12]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [13]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [14]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [15]

from #Cash


MonthNumber 1 2 3 4 5 6 7

Total 4.13 NULL NULL NULL NULL 51.33 NULL

8 9 10 11 12 13 14 15

NULL NULL 51.33 NULL 32.45 0 0 0

Why there is null in the output? how can we resolve it?


Strange problem with case statement

See full illustration here



CREATE TABLE #T
(
Months int,
Cash decimal(10,2)
)
insert #T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0


declare @monthList varchar(max),@sql varchar(max)
set @monthList= STUFF((select ',[' + CAST(Months as varchar(2)) + ']' FROM #t for xml path('')),1,1,'')

set @sql = 'SELECT ' + @MonthList + 'FROM #T PIVOT(MAX(Cash) FOR Months IN (' + @monthList + '))p'

EXEC (@sql)
DROP TABLE #T







Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Strange problem with case statement

You may try with PIVOT:



CREATE TABLE #T
(
Months int,
Cash decimal(10,2)
)
insert #T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0

SELECT 'Cash' AS Cash,
[1], [2], [3], [4],[5],[6],[7],[8],[9],[10],[11],[12]
FROM
(SELECT months,Cash
FROM #T) AS SourceTable
PIVOT
(
MAX(Cash)
FOR Months IN ([1], [2], [3], [4],[5],[6],[7],[8],[9],[10],[11],[12])
) AS PivotTable;

Drop table #T


Strange problem with case statement

Try the Below one It working as expected



Declare @T as Table
(
Months int,
Cash Float
)
insert @T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0

select 'Total' as Months
,Cast(max(case when Cash = '4.13' then Cash end) as varchar(20)) [1]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [2]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [3]
,Cast(max(case when Cash = '5.31' then Cash end) as varchar(20)) [4]
,Cast(max(case when Cash = '5.31' then Cash end) as varchar(20)) [5]
,Cast(max(case when Cash = '51.33' then Cash end) as varchar(20)) [6]
,Cast(max(case when Cash = '393.53' then Cash end) as varchar(20)) [7]
,Cast(max(case when Cash = '393.53' then Cash end) as varchar(20)) [8]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [9]
,Cast(max(case when Cash = '51.33' then Cash end) as varchar(20)) [10]
,Cast(max(case when Cash = '57.82' then Cash end) as varchar(20)) [11]
,Cast(max(case when Cash = '32.45' then Cash end) as varchar(20)) [12]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [13]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [14]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [15]
from @T




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


Strange problem with case statement

I'm using Dynamic sql. Table variable will not work. Why it is showing unexpected result using temp table.

Strange problem with case statement

Could you show us your code. We would be able to help you.

Strange problem with case statement


I'm using Dynamic sql. Table variable will not work. Why it is showing unexpected result using temp table.



Then you did not understand Ganesh's answer. He showed you that with data you posted, your SELECT statement gave the expected output. He only used a table variable to put your data into SQL.


From this we can conclude that whatever issue you have it is with something

you are not telling us.


Oh, some people told you to use the PIVOT operator. Don't listen to them. Your code is the right way to do a pivot. The PIVOT operator does not give much benefit and puts you in a straight-jacket. Using CASE like you did gives more flexible. And it runs on other engines too.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Strange problem with case statement

Also, this derivative of Ganesh's answer yields the same response, and is amount-neutral:



select 'Total' as Months
,Cast(max(case when Months = '01' then Cash end) as varchar(20)) [1]
,Cast(max(case when Months = '02' then Cash end) as varchar(20)) [2]
,Cast(max(case when Months = '03' then Cash end) as varchar(20)) [3]
,Cast(max(case when Months = '04' then Cash end) as varchar(20)) [4]
,Cast(max(case when Months = '05' then Cash end) as varchar(20)) [5]
,Cast(max(case when Months = '06' then Cash end) as varchar(20)) [6]
,Cast(max(case when Months = '07' then Cash end) as varchar(20)) [7]
,Cast(max(case when Months = '08' then Cash end) as varchar(20)) [8]
,Cast(max(case when Months = '09' then Cash end) as varchar(20)) [9]
,Cast(max(case when Months = '10' then Cash end) as varchar(20)) [10]
,Cast(max(case when Months = '11' then Cash end) as varchar(20)) [11]
,Cast(max(case when Months = '12' then Cash end) as varchar(20)) [12]
,Cast(max(case when Months = '13' then Cash end) as varchar(20)) [13]
,Cast(max(case when Months = '14' then Cash end) as varchar(20)) [14]
,Cast(max(case when Months = '15' then Cash end) as varchar(20)) [15]
from @T


Strange problem with case statement

I ran your code Asmasm11, I did not get any NULLS.


!!!




Please use Mark as Answer; if my reply solved your problem. Use Vote As Helpful if a post was useful. |http://ift.tt/1cCGy04 | |+91-9742-354-384 |


Static class

A static instance or something is usually shared by different kinds of a certain type, it doesn't belong to instance itself, no matter how many instances of the type you've created.


ASP.NET Forum

Other Discussion Forums

FreeRice Donate

Issues to report

Free Tech Books Search and Download


Strange problem with case statement

I ran your code Asmasm11, I did not get any NULLS.


!!!




Please use Mark as Answer; if my reply solved your problem. Use Vote As Helpful if a post was useful. |http://ift.tt/1cCGy04 | |+91-9742-354-384 |


MediaElement won't play after returning from multitasking

how you calling the play button? to you set the source before? then you need to wait till the is loaded (CurrentStateChanged).


Microsoft Certified Solutions Developer - Windows Store Apps Using C#


Start Background Task at startup

H! I want to know if I have a background task for an Window 8 app, is it possible to make it start when the computer starts up? Not immediately but in the next 1-2 minutes.


Cris


Start Background Task at startup

I tried to do this but it doesn't trigger when I start the computer. It's not necessarily for me to implement something like this, I just wanted to know if you can do it.


Cris


Start Background Task at startup

I'll see what I can do.


Cris


Thursday, February 27, 2014

Unix command for dot net

ask in a linux community, this has nothing to do with C#.




Visual C++ MVP

need help!! please.. :'( Different User Accessing Different Form in C#

I also did try using mySql.. but still no luck.. really need help.. hope someone can help me..

need help!! please.. :'( Different User Accessing Different Form in C#


if((username.Equals("a") == true) && (password.Equals("a") == true))
{
var newForm2 = new Form2();
newForm2.Show();
}
if((username.Equals("b") == true) && (password.Equals("b") == true))
{
var newForm3 = new Form3();
newForm3.Show();
}

I'm not exactly sure what you're looking for, but will something like this help? I could be wrong ... I'm not quite sure what your question is.



need help!! please.. :'( Different User Accessing Different Form in C#

I'm still lost. Let's try this: explain to us, without using code, what you're trying to do. What is the requirement that you're trying to implement?


need help!! please.. :'( Different User Accessing Different Form in C#

first, i wanted to say thanks for helping..


i want to create a login system where the different users access different form..


i create 2 button. 1st is the register button where that person can enter what name and password their want..


and the second button is login button.. but my problem is now, although different username and password been used, it still accessed the same form..


hope you can understand this.. i'm so sorry once more



need help!! please.. :'( Different User Accessing Different Form in C#

Have the forms you are trying to access already been created and available, or will they need to be created when the button is clicked?

need help!! please.. :'( Different User Accessing Different Form in C#

the form is already been created and available..

need help!! please.. :'( Different User Accessing Different Form in C#



foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["user"] == textBox1.Text) //right USER!!!
{
if (dr["password"] = textBox2.Text) //also password is right
return true;



Form3 fm3 = new Form3();
fm3
.Show(); // i need to add this? is it ok?




else
return false; //wrong password
}
}

need help!! please.. :'( Different User Accessing Different Form in C#

but if that the case, then do i determined the person username?


i am so sorry for asking a lot. thank you very much for helping.. i am very grateful


need help!! please.. :'( Different User Accessing Different Form in C#

ok. that should be fine.. but if other username accessed everything will go to form 2.. right?


linked server issue on sql 2000 sp4

anyone ??

linked server issue on sql 2000 sp4

I don't have an answer for you.


If I were in your situation, then at the very least I would:



  • check if the query runs without errors when submitted directly to Oracle

  • somehow find out if the latest ODBC/Oracle driver is on the server

  • experiment with the Provider (ODBC vs Oracle provider) of the linked server

  • rule out network connection/instability problems

  • if you also have a newer SQL Server running somewhere: try it from there, and see if it makes a difference


Good luck.




Gert-Jan


linked server issue on sql 2000 sp4

Hi skc_chat,


It seems this issue have been fixed after install Microsoft SQL Server 2000 Service Pack 4. Please refer to the following article:

FIX: "Connection is busy with results for another command" error message occurs when you run a linked server query: http://ift.tt/NBtthC


Please try to install the latest CU for SQL Server 2000 SP4 to see if this helps. We can find it from the link below:

http://ift.tt/1mlEDS6


In addition, Microsoft have ended SQL Server 2000 support. Please consider upgrading to latest version of SQL Server as soon as possible.

Upgrading to SQL Server 2008 R2: http://ift.tt/NBtuSL
Upgrade to SQL Server 2012: http://ift.tt/NBttya


Regards,




Elvis Long

TechNet Community Support



One Clustered Index

Why only one clustered Index in SQL Server? Can you please explain in more detail?


One Clustered Index


Why only one clustered Index in SQL Server? Can you please explain in more detail?





Clustered index sorts whole table in a particular order according to cluster key .You cannot have two order in which table can be sorted .If there were 2 PK they would try to sort them in 2 order which is not possible so only one PK is allowed.



Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers


One Clustered Index

Adding to Shanky's point, HOWEVER....you can create clustered index with combination of columns(Composite) which means the SORT happens according to the combination of columns(leading and preceding).


Ref:http://ift.tt/1huCwxo



Unix command for dot net

hi all,


I am connected to linux machine.Now i want to search for particular softwares.Like i want to search for software whose names starts with "Micro*". So that i get list of all microsoft products listed on that system. Can any one please provide light on the command i require.Can i perform this can kind of search using command.The reason is When i am running "rpm -qa | less", m getting lots of data which is becoming difficult to manage.


Please help me.


Regards,


Neil


Need a PIVOT-like solution

;with cte as (select PatientID, LabDate, ROW_NUMBER() over (partition by PatientID ORDER BY LabDate) as Rn FROM dbo.LabsPerPatient)


SELECT * from cte PIVOT (max(LabDate) FOR Rn IN ([1],[2],[3],[4])) pvt


-------------------


The above will display 4 first dates per patient.




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





My blog




My TechNet articles



Need a PIVOT-like solution

We are running SQL Server 2008R2.

Need a PIVOT-like solution

Did you see that I asked 2 questions? What is the compatibility level of the database?


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





My blog




My TechNet articles


Need a PIVOT-like solution

In this case you would need a dynamic PIVOT. There are many samples in the forum or you can check my article


http://ift.tt/1fo2Vee




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





My blog




My TechNet articles


Need a PIVOT-like solution

When I run it I get

Invalid column name 'compatiblity_level'.


Need a PIVOT-like solution

Ok, correct the typo (which I did) and re-run the query.


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





My blog




My TechNet articles


Need a PIVOT-like solution

Compatibility level is 80 on that database (it came from an old 2000 or 2005 db).

Need a PIVOT-like solution

select count(LabDate) from dbo.LabsPerPatient where PatientID = @PatientID


to find how many you will need for your current data.


Check the article I recommended, it explains how to do this dynamically (find the maximum number of rows per a patient and generate the query you need).




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





My blog




My TechNet articles


Need a PIVOT-like solution

No wonder you get lots of NULLs.


I see the problem and you will see it too if you read this article


http://ift.tt/1dcmm5B




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





My blog




My TechNet articles


Need a PIVOT-like solution

BTW, why do you need the ID column (PatientLabsId) and LabValue in your result? How exactly do you envision your result to be?


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





My blog




My TechNet articles


Need a PIVOT-like solution

Can you please post DDL of all tables involved with some data (as insert statements) and your desired result based on that data?


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





My blog




My TechNet articles


Need a PIVOT-like solution

I will do this soon. Just have emergency to deal with.

Need a PIVOT-like solution

I will do this soon. Just have emergency to deal with.

Hello,


Have you solved this issue? Please let us know how things go.


Regards,




Elvis Long

TechNet Community Support



Get distinct records if more than one select column

Looks like this to me



SELECT ParentId,refid,TaskNo,TaskOwner,UpdatedBy,Remarks,Description
FROM
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY ParentId ORDER BY refid) AS Seq
)t
WHERE Seq =1





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Get distinct records if more than one select column

Thank you for quick reply..


Please let me know where is the table name ?


Accessing Sysprep.exe using a program written in C#

Hi, please try this minor change:



using System.Diagnostics;

class Program
{
static void Main()
{
Process.Start(@"C:\Windows\System32\Sysprep\sysprep.exe");
}
}


Accessing Sysprep.exe using a program written in C#

The Sysprep folder is a read only folder in System 32. I was getting the same File not found error. Essentially, this will work if you execute your program in release mode. For running this in debug mode, use the below code.


Use the LeaveDebugMode to allow System.Diagnostics.Process component of out the state that


lets you interact with OS processes that run in special mode. The below code worked for me:


System.Security.SecureString pwd = new System.Security.SecureString();

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');


Process.LeaveDebugMode();


Process.Start("C:\\windows\\system32\\sysprep\\sysprep.exe", "<enter your user ID>", pwd, "<enter your domain>");

Process.EnterDebugMode();

Code Error: Cannot Convert String into Bool! Need Help

Characters in double quotes are strings, not variables.


Writing...


bool "jake" = true;


would be a bit like writing...


int 1 = 2;


That is, is would be trying to assign a value to something which already has a literal value.


Code Error: Cannot Convert String into Bool! Need Help

Thank you very much!


Code Error: Cannot Convert String into Bool! Need Help

Okay, didn't know if that variable could make it true or not; still learning

Get distinct records if more than one select column

Looks like this to me



SELECT ParentId,refid,TaskNo,TaskOwner,UpdatedBy,Remarks,Description
FROM
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY ParentId ORDER BY refid) AS Seq
)t
WHERE Seq =1





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Get distinct records if more than one select column

Thank you for quick reply..


Please let me know where is the table name ?


Get distinct records if more than one select column

Ah sorry tht was atypo



SELECT ParentId,refid,TaskNo,TaskOwner,UpdatedBy,Remarks,Description
FROM
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY ParentId ORDER BY refid) AS Seq
FROM TableName
)t
WHERE Seq =1





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


impact of assigning dbowner privelege to a user/login

Hello,


If I assign dbowner privelege to a login/user would that user be able to access all the objects in that specific database or the objects owned by the user only.


Best regards,


Vishal


impact of assigning dbowner privelege to a user/login

Hi,


db_owner owns the whole database, so can access and manipulate and alter all objects within its database boundaries.




Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu


impact of assigning dbowner privelege to a user/login


Hello,


If I assign dbowner privelege to a login/user would that user be able to access all the objects in that specific database or the objects owned by the user only.


Best regards,


Vishal



Hi Vishal,


Members of the db_owner fixed database role can perform all configuration and maintenance activities on the database, and can also drop the database. For more information regarding Server and database roles in SQL Server, please see:

http://ift.tt/Nai3S8


Regards,




Elvis Long

TechNet Community Support



MediaElement won't play after returning from multitasking

I have a simple app that plays a media element that I declare and give source to in the MainPage.xaml file. A bug I have noticed is after leaving the app and returning, the media element no longer plays. The function that triggers it is in the MainPage.xaml.cs and I have set up markers to verify the function is being called and executing correctly. For some reason, the media element is simply not playing.


I am using the .Play() function, and it works with no errors as long as I don't navigate out of the app. Any ideas?


How to populate a GridView using inline GridViewItems to test DataTemplate?

Hello,


Frequently I find myself making mock prototypes of C# WinRT apps and need to quickly populate a GridView with data. I will have already designed the ItemTemplate for the GridViewItem within the GridView item's Datatemplate (including the binding value names). Since this is a quick mockup I don't have the backend built out. Right now the only two ways I know of quickly populating the GridView for my needs are:


1) paste the GridViewItemTemplate into each GridViewItem and change the values from Binding Values to the real values:



<GridView >
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" Margin="0 0 0 5"/>
<TextBlock Text="{Binding Address}" Margin="0 0 0 5"/>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>

<GridViewItem>
<StackPanel>
<TextBlock Text="Simon Smith" Margin="0 0 0 5"/>
<TextBlock Text="125 Maple Avenue" Margin="0 0 0 5"/>
</StackPanel>
</GridViewItem>

<GridViewItem>
<StackPanel>
<TextBlock Text="Janet Janks" Margin="0 0 0 5"/>
<TextBlock Text="56 Brooks St." Margin="0 0 0 5"/>
</StackPanel>
</GridViewItem>

</GridView>



2: Define a list of objects in the code behind with all the binding properties defined and set this list as the GridView's item source (this is a bit too time consuming for my mockup needs)


Is there a way I can populate the GridView with GridViewItems specifying the binding values as item properties?


ideally I was hoping for something quick like this:



<GridViewItem Name="Mr. Smith" Address="123 Maple Avenue" />
<GridViewItem Name="Mrs. Janks" Address="56 Brooks St." />
<GridViewItem Name="Mr. Holden" Address="9005 Central Ave"/>





What is the quickest way to handle this? Is this something where I could define my own GridViewItems and add my own dependency properties?


Thanks!







How to populate a GridView using inline GridViewItems to test DataTemplate?

Hi twubneh,


That would be a good suggestion, but I don't think it is possible by now.


The only way to use Name/Address attribute in GridViewItem is to attach an dependency property, which might be much more complicate than just use binding.


--James




<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>

Thanks

MSDN Community Support



Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


Strange problem with case statement

I got into an issue with the below statement. I don’t understand why it is not working as expected. Structure for table is below

Months Cash

1 4.13

2 46.02

3 46.02

4 5.31

5 5.31

6 51.33

7 393.53

8 393.53

9 46.02

10 51.33

11 57.82

12 32.45

13 0

14 0

15 0

select ‘Total’ as Months

,Cast(max(case when Cash = ’4.13′ then Cash end) as varchar(20)) [1]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [2]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [3]

,Cast(max(case when Cash = ’5.31′ then Cash end) as varchar(20)) [4]

,Cast(max(case when Cash = ’5.31′ then Cash end) as varchar(20)) [5]

,Cast(max(case when Cash = ’51.33′ then Cash end) as varchar(20)) [6]

,Cast(max(case when Cash = ’393.53′ then Cash end) as varchar(20)) [7]

,Cast(max(case when Cash = ’393.53′ then Cash end) as varchar(20)) [8]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [9]

,Cast(max(case when Cash = ’51.33′ then Cash end) as varchar(20)) [10]

,Cast(max(case when Cash = ’57.82′ then Cash end) as varchar(20)) [11]

,Cast(max(case when Cash = ’32.45′ then Cash end) as varchar(20)) [12]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [13]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [14]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [15]

from #Cash


MonthNumber 1 2 3 4 5 6 7

Total 4.13 NULL NULL NULL NULL 51.33 NULL

8 9 10 11 12 13 14 15

NULL NULL 51.33 NULL 32.45 0 0 0

Why there is null in the output? how can we resolve it?


Strange problem with case statement

See full illustration here



CREATE TABLE #T
(
Months int,
Cash decimal(10,2)
)
insert #T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0


declare @monthList varchar(max),@sql varchar(max)
set @monthList= STUFF((select ',[' + CAST(Months as varchar(2)) + ']' FROM #t for xml path('')),1,1,'')

set @sql = 'SELECT ' + @MonthList + 'FROM #T PIVOT(MAX(Cash) FOR Months IN (' + @monthList + '))p'

EXEC (@sql)
DROP TABLE #T







Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Strange problem with case statement

You may try with PIVOT:



CREATE TABLE #T
(
Months int,
Cash decimal(10,2)
)
insert #T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0

SELECT 'Cash' AS Cash,
[1], [2], [3], [4],[5],[6],[7],[8],[9],[10],[11],[12]
FROM
(SELECT months,Cash
FROM #T) AS SourceTable
PIVOT
(
MAX(Cash)
FOR Months IN ([1], [2], [3], [4],[5],[6],[7],[8],[9],[10],[11],[12])
) AS PivotTable;

Drop table #T


Strange problem with case statement

Try the Below one It working as expected



Declare @T as Table
(
Months int,
Cash Float
)
insert @T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0

select 'Total' as Months
,Cast(max(case when Cash = '4.13' then Cash end) as varchar(20)) [1]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [2]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [3]
,Cast(max(case when Cash = '5.31' then Cash end) as varchar(20)) [4]
,Cast(max(case when Cash = '5.31' then Cash end) as varchar(20)) [5]
,Cast(max(case when Cash = '51.33' then Cash end) as varchar(20)) [6]
,Cast(max(case when Cash = '393.53' then Cash end) as varchar(20)) [7]
,Cast(max(case when Cash = '393.53' then Cash end) as varchar(20)) [8]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [9]
,Cast(max(case when Cash = '51.33' then Cash end) as varchar(20)) [10]
,Cast(max(case when Cash = '57.82' then Cash end) as varchar(20)) [11]
,Cast(max(case when Cash = '32.45' then Cash end) as varchar(20)) [12]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [13]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [14]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [15]
from @T




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


Strange problem with case statement

I'm using Dynamic sql. Table variable will not work. Why it is showing unexpected result using temp table.

Strange problem with case statement

Could you show us your code. We would be able to help you.

Strange problem with case statement


I'm using Dynamic sql. Table variable will not work. Why it is showing unexpected result using temp table.



Then you did not understand Ganesh's answer. He showed you that with data you posted, your SELECT statement gave the expected output. He only used a table variable to put your data into SQL.


From this we can conclude that whatever issue you have it is with something

you are not telling us.


Oh, some people told you to use the PIVOT operator. Don't listen to them. Your code is the right way to do a pivot. The PIVOT operator does not give much benefit and puts you in a straight-jacket. Using CASE like you did gives more flexible. And it runs on other engines too.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Mixed mode assembly is built against version ''v1.1.4322'

How can that be ? Ive downloaded DiretXSDK a few days ago.. o_O


And is there something to with this ? (the image)


Screenshot


Ive add the dll files to the references from the first folder..


System.IndexOutOfRangeException

Check the ‘GetCustomer’ stored procedure and make sure it returns the ‘Naslov1’ column.


System.IndexOutOfRangeException

When i replace Naslov1 with Street it works. So i guess i can get info from 'Naslov1'

System.IndexOutOfRangeException

Hi


I don't know how your code is working without a connection object and without opening the connection.


Well but I would answer your query.


It depends open the select query in your stored procedure.


If the select query is like


Select * from Customers


and as you said Naslov1 is in the same table then you will not get any error. But if the select query is like


Select IdCustomer, Name, SurName, Street From Customer then you will get this error.


Strange problem with case statement

Could you show us your code. We would be able to help you.

Excel 2013 cell mapping to SQL 2008 colums

Im not having luck with the export/import wizard to "map" and the SSIS is very new to me. Perhaps point me to some tutorials or examples so that I can review.


thank you,


Jennifer




JenniferM


sum(data) between two dates and its interval dates

Hi all ,


I need to get the data from startdate parameter to start date +1 ,


startdate +2 to startdate +3 , startdate +4 to startdate+7 and startdate +8 to Enddate


this should be top headar


and left side status


(like cross tab )


and in the data part i need to get the sum of data .


Please help me on this




Regards, Subathra


sum(data) between two dates and its interval dates

Please post sample data + desired result. Take a look at Matrix control


Best Regards,Uri Dimant SQL Server MVP, http://ift.tt/1iQ9JkR



MS SQL optimization: MS SQL Development and Optimization

MS SQL Consulting: Large scale of database and data cleansing

Remote DBA Services: Improves MS SQL Database Performance

SQL Server Integration Services: Business Intelligence


sum(data) between two dates and its interval dates

Here is the sample data



1 day has to be start date


and last >31 day contained endstart




Regards, Subathra



Strange problem with case statement

I'm using Dynamic sql. Table variable will not work. Why it is showing unexpected result using temp table.

Excel 2013 cell mapping to SQL 2008 colums

Use SQL ImportAndExpot Wizard or SQl Intergaration Services




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


Excel 2013 cell mapping to SQL 2008 colums

Thanks for replying, Vishak


The data in the excel sheet will be filled out and saved. At that point the data in the excel is static. I need to map that data to SQL columns.




JenniferM


unable to use Visual Studio 2010 in SharePoint 2010 server

one more input. If i start using sandbox project the project opens. But unable to add items like Workflow etc.


cannot connect to the sharepoint site error comes.


Warm Regards,


Sathya


Contet type not able to edit

No sure what you are trying, however you can edit settings on content type with:-


Goto site settings-> Site Content types -> select your content type -> and edit various options whatever you need


If you are trying to edit items in a list with inline editing option then i dont think you will get an option to change content type, you only get it when you edit it in a model dialog popup






Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL

INSQLSERVER.COM Mohammad Nizamuddin

Wednesday, February 26, 2014

System.IndexOutOfRangeException



public static Customer GetCustomer(int idCallActionItem)
{
Customer result = new Customer();

SqlCommand cmd = new SqlCommand("GetCustomer");
cmd.CommandType = CommandType.StoredProcedure;

SqlParameter param1 = new SqlParameter("@idCallActionItem", SqlDbType.Int);
param1.Value = idCallActionItem;

cmd.Parameters.Add(param1);


SqlDataReader reader = Database.ReturnExecuteReader(cmd);

if (reader.Read())
{






result.IdCustomer = Convert.ToInt32(reader["IdCustomer"].ToString());
result.Surname = reader["Surname"].ToString();
result.Name = reader["Name"].ToString();
result.Street = reader["Street"].ToString();
//result.Nasl = reader["Naslov1"].ToString(); //error





Additional information: Naslov1



Naslov1 is same table as Street. I dont know why i get error if someone can explain to me why i get error



and how can i fix it. Thx for your answers.

Strange problem with case statement

Try the Below one It working as expected



Declare @T as Table
(
Months int,
Cash Float
)
insert @T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0

select 'Total' as Months
,Cast(max(case when Cash = '4.13' then Cash end) as varchar(20)) [1]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [2]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [3]
,Cast(max(case when Cash = '5.31' then Cash end) as varchar(20)) [4]
,Cast(max(case when Cash = '5.31' then Cash end) as varchar(20)) [5]
,Cast(max(case when Cash = '51.33' then Cash end) as varchar(20)) [6]
,Cast(max(case when Cash = '393.53' then Cash end) as varchar(20)) [7]
,Cast(max(case when Cash = '393.53' then Cash end) as varchar(20)) [8]
,Cast(max(case when Cash = '46.02' then Cash end) as varchar(20)) [9]
,Cast(max(case when Cash = '51.33' then Cash end) as varchar(20)) [10]
,Cast(max(case when Cash = '57.82' then Cash end) as varchar(20)) [11]
,Cast(max(case when Cash = '32.45' then Cash end) as varchar(20)) [12]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [13]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [14]
,Cast(max(case when Cash = '0' then Cash end) as varchar(20)) [15]
from @T




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


For Creating Date Columns Dynamically

I had already posted the solution in your last thread


see


http://ift.tt/1cOmTxL




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


For Creating Date Columns Dynamically

Here , i need W.R.T Month Bro not year...


And the Solution in Blog is tuf for my understanding.


Can u help me in Some other way.


For Creating Date Columns Dynamically

Its just a simple change you need to do.just apply convertion logic to change dates to month dates


see below post


http://ift.tt/1eyELsM



then use it in logic to create list as in the previous link and finally create pivot query with it


I want you to TRY and LEARN this rather than giving you a spoonfed answer.


If you face any issues while trying we're here to help you out


Unless you try it out yourselves you're never going to learn this.




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


For Creating Date Columns Dynamically

Satish,


Check if this helps:



create table #temp (id int identity(1,1),name varchar(100), date datetime)


insert #temp(name,date) select 'jk','2014/01/01'
insert #temp(name,date) select 'jk','2014/01/01'
insert #temp(name,date) select 'jk','2014/01/01'
insert #temp(name,date) select 'jay','2014/01/02'
insert #temp(name,date) select 'jay','2014/01/02'
insert #temp(name,date) select 'jk','2014/01/02'
insert #temp(name,date) select 'Kumaur','2014/01/01'
insert #temp(name,date) select 'Kumaur','2014/01/02'
insert #temp(name,date) select 'Kumaur','2014/01/03'
insert #temp(name,date) select 'jk','2014/01/03'
insert #temp(name,date) select 'jk','2014/02/03'
insert #temp(name,date) select 'jk','2014/02/03'
insert #temp(name,date) select 'Jay','2014/02/01'

--select * from #temp order by name

/*
--normal method using PIVOT
select *
from
(
select id,name,date from #temp
) tab
PIVOT
(
count(id) for date in([01/01/2014],[01/02/2014],[01/03/2014])
) pvt

*/
--Dynamic PiVOT to fit in the range of dates as per user input of @Year and @month - 1 for Jan, 2 for Feb and so on..
--Provides data for all the columns available in the table
declare @month int,@year int,@date_list nvarchar(max),@sql nvarchar(max)

--Give the Month input here
set @year=2014
set @month=1
set @date_list=''

select @date_list=@date_list+',['+isnull(convert(varchar,date,101),'')+']'
from (Select distinct date from #temp
where datepart(mm,date)=@month and datepart(yyyy,date)=@year) tt


--set @date_list=stuff(@date_list,1,1,'')

set @sql='
select *
from
(
select id,name,date from #temp
) tab
PIVOT
(
count(id) for date in('+stuff(@date_list,1,1,'')+')
) pvt'

print @sql
exec sp_executesql @sql





Thanks,

Jay

<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>


How to get list name through javascript?

Hi Prasanth,


Actually we have somany lists in my subsite so I wanna write this code globally thats why Im looking for find list automatically. And Here my js file is attached to button on dispForm aspx page of list. when click on button it will update my list fields.


I could solve my prob ..


Anyway thank you for reply.





Add Control Dynamically to SharePoint list page

I have custom control need to register on the Edit page of the document library. These libraries are already existing on the customer instances. Need to find some way to register and add the control to Edit page of the selected library on the fly programatically with SharePoint object model.


The custom control handles our business logic to redirect the page to site home page.


Your help is greatly appreciated!!




Bala



data/routine change in .cs File without my awareness using VSS issue


our company still use VSS for dotnet project file version management. one wired things happen frequently that file data is getting change and when i am seeing view history then it is showing my name that i have change the file data.


in my development team there is some dangerous developer who has admin rights for VSS and i have no admin rights. i know that i have not change the file data but VSS showing my name. i guess some user with admin right is doing something in my back. i am looking for help how to capture the GHOST in development team.


i like to know that any user with admin right can change the file data also change file changed user name.....is that kind of provision is there? i am in huge trouble so any expert in VSS please help me.


our company is not going to change our version control system. so i have to use only VSS. looking for guide line how to work and how to capture the ghost who change my file routine but his name is not showing rather my name is showing instead. thanks.



data/routine change in .cs File without my awareness using VSS issue

thanks for reply. i really do not know how to see the login log?


VSS store every user credential detail in any file. so i like to know is there any tool exist by which one can extract user credential from where VSS store those in a file.


anyone can hack info from vss data using any tool or use any other technique?


please suggest me. thanks


Strange problem with case statement

I got into an issue with the below statement. I don’t understand why it is not working as expected. Structure for table is below

Months Cash

1 4.13

2 46.02

3 46.02

4 5.31

5 5.31

6 51.33

7 393.53

8 393.53

9 46.02

10 51.33

11 57.82

12 32.45

13 0

14 0

15 0

select ‘Total’ as Months

,Cast(max(case when Cash = ’4.13′ then Cash end) as varchar(20)) [1]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [2]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [3]

,Cast(max(case when Cash = ’5.31′ then Cash end) as varchar(20)) [4]

,Cast(max(case when Cash = ’5.31′ then Cash end) as varchar(20)) [5]

,Cast(max(case when Cash = ’51.33′ then Cash end) as varchar(20)) [6]

,Cast(max(case when Cash = ’393.53′ then Cash end) as varchar(20)) [7]

,Cast(max(case when Cash = ’393.53′ then Cash end) as varchar(20)) [8]

,Cast(max(case when Cash = ’46.02′ then Cash end) as varchar(20)) [9]

,Cast(max(case when Cash = ’51.33′ then Cash end) as varchar(20)) [10]

,Cast(max(case when Cash = ’57.82′ then Cash end) as varchar(20)) [11]

,Cast(max(case when Cash = ’32.45′ then Cash end) as varchar(20)) [12]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [13]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [14]

,Cast(max(case when Cash = ’0′ then Cash end) as varchar(20)) [15]

from #Cash


MonthNumber 1 2 3 4 5 6 7

Total 4.13 NULL NULL NULL NULL 51.33 NULL

8 9 10 11 12 13 14 15

NULL NULL 51.33 NULL 32.45 0 0 0

Why there is null in the output? how can we resolve it?


Strange problem with case statement

See full illustration here



CREATE TABLE #T
(
Months int,
Cash decimal(10,2)
)
insert #T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0


declare @monthList varchar(max),@sql varchar(max)
set @monthList= STUFF((select ',[' + CAST(Months as varchar(2)) + ']' FROM #t for xml path('')),1,1,'')

set @sql = 'SELECT ' + @MonthList + 'FROM #T PIVOT(MAX(Cash) FOR Months IN (' + @monthList + '))p'

EXEC (@sql)
DROP TABLE #T







Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Strange problem with case statement

You may try with PIVOT:



CREATE TABLE #T
(
Months int,
Cash decimal(10,2)
)
insert #T
select 1, 4.13 union all
select 2 ,46.02 union all
select 3 ,46.02 union all
select 4 ,5.31 union all
select 5 ,5.31 union all
select 6 ,51.33 union all
select 7 ,393.53 union all
select 8 ,393.53 union all
select 9 ,46.02 union all
select 10, 51.33 union all
select 11 ,57.82 union all
select 12 ,32.45 union all
select 13 ,0 union all
select 14 ,0 union all
select 15 ,0

SELECT 'Cash' AS Cash,
[1], [2], [3], [4],[5],[6],[7],[8],[9],[10],[11],[12]
FROM
(SELECT months,Cash
FROM #T) AS SourceTable
PIVOT
(
MAX(Cash)
FOR Months IN ([1], [2], [3], [4],[5],[6],[7],[8],[9],[10],[11],[12])
) AS PivotTable;

Drop table #T


Excel 2013 cell mapping to SQL 2008 colums

Without knowing how tool fetches the data its not easy to suggest. How does it pull the data to columns? Is it through VBA coding?


Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Design time data not visible for Win8.0 apps on Win 8.1

thank you for confirming this, did this actually get logged as a bug? if I'm doing something wrong, or if there's something I can do to make this work I'd sure like to know.


Unfortuately I cannot update/retarget my app to 8.1, i need to first update the 8.0 version, but I'm doing it blind, because no matter what I try to do, I cannot get any data to show up in my gridview.


Is it possible to simply replace the GridView with a ListView and have the listview lay the items out like a grid? I recall reading somewhere they are interchangeable, but can't find any specific resources telling me how to do it.


last question: is there any place I can track the status of the bug (assuming that's what it is)?


thank you again for your help


josh


Design time data not visible for Win8.0 apps on Win 8.1

Hi josh


Sorry, currently there is no place to track WinRT bugs. Connect is the only site for bugs but they do not accept winrt bugs. However I already reported this to seniors.


Make a ListView looks like GirdView? Take a look at this: Item templates for grid layouts, Is this what you need? By setting the following code we should be able to make ListView looks like GridView.



<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="8"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>

--James



<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>

Thanks

MSDN Community Support



Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



Design time data not visible for Win8.0 apps on Win 8.1

I ended up fixing this and enabling the design-time data again by modifying the ItemsPanelTemplate of the GridView to be a VariableSizedWrapGrid. Simply adding this to the GridView:



<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid />
</ItemsPanelTemplate>
</GridView.ItemsPanel>

seems to do the trick. Perhaps there is a bug in the regular WrapGrid when opening a Windows 8 app project on Windows 8.1? I'm sure the frequency of this is so low it's probably not worth doing anything about it, but hopefully someone who does search for this finds this helpful.


PS regarding making the ListView look like GridView (or vice versa) it occured to me that this would be a nice way to handle changing from filled to "snap" view, instead of having to maintain two separate controls and templates, you could simply relay it out...


I didn't have much luck with this, but it's something I've always wondered about. anyway that's another topic, thanks for your help and attention!


Export to Excel Issue - Background Colors

Hi obrienkev,


In order to trouble shoot this issue more efficiently, could you tell me what’s the function of this code you posted? What do you want to do with this code? Could you explain it more details?


As to your issue, please try to directly export the report to Excel to check this issue again. Are you get the correct background color in the report or with the same issue? Tell us more detail information, then we can make further analysis.


Thank you for your understanding.


Regards,

Katherine xiong


If you have any feedback on our support, please click here.




Katherine Xiong

TechNet Community Support



Cannot select dataset for Table inside List

You cant associate a different dataset for the child


What you can do is to create a dummy dataset and assign parent and child to it. then inside tables you can invoke fields using Scope as required dataset to display it


. So if you want the sum of field from dataset2 in child use



=SUM(Fields!FieldName.value,"dataset2")



etc




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


How to get list name through javascript?

Hi,


I wrote javascript for getting list items but here I'm hard coded list name as "Projects"(my list name). How can I get list name automatically with out hard coding,


Appreciate if anyone help.


Thank you.



function DoLogicalDelete()
{

var clientContext = null;
var oList = null;
var oListItem = null;
// var lstItmIsDeleted = null;

var itmID = getQuerystring('ID');

clientContext = SP.ClientContext.get_current();

oList = clientContext.get_web().get_lists().getByTitle('Projects');


// var oListItemID = SP.ListOperation.Selection.getSelectedItems(clientContext);


oListItem = oList.getItemById(itmID); // getting ID

clientContext.load(oListItem,"Title", "IsDeleted"); // load items to oListItem


oListItem.set_item('IsDeleted', true);
oListItem.update();

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}


How to get list name through javascript?

Not sure on which context you are executing the code. If you executing this from the list form and trying to get the current list, then you may need to get the list name from the breadcrumb/list title field. Refer to the following posts for more information


http://ift.tt/1cT58xl


http://ift.tt/1cT56p3




--Cheers


How to get list name through javascript?

Hi Prasanth,


Actually we have somany lists in my subsite so I wanna write this code globally thats why Im looking for find list automatically. And Here my js file is attached to button on dispForm aspx page of list. when click on button it will update my list fields.


I could solve my prob ..


Anyway thank you for reply.





Delete file from folder only (not from list)

Hi all,


I've searched a lot and didn't succeed so far, that's why I need your help. In a cloud context, I'm actually creating and uploading files (pdf and/or xml files) "on the go" to sharepoint folders via the SOAP API and this is perfectly working. But in a cloud context, I also need to decomission services which is translated into deleting files into Sharepoint.


That's where it became complicated, because according to the API we cannot delete files if they are not part of a list structure, which is not my case. Is that true ?


The only info I have when trying to delete a file via the SOAP Api is : its name, its folder, and the endpoint where the folder is. So my question remains simple I guess : is this possible ? If so, how to (a link to the SOAP body would be usefull)


Thanks a lot

Regards


Baptiste


Document Control Register

Hi all,


I am in the process of designing a spreadsheet for a Document Control register, this obviously is going to have Fields for date opened and date closed, document number, document error codes, i.e. if document is returned for Formatting or Technical Issues, the ECN number it is changed under, date completed, and the customer that the document went to....


Does anybody have any amazing ideas, that I could incorporate into this spreadsheet to make it workable and dynamic, obviously I will be presenting information from the data held to display in the form of graphs etc....


Thanks for your help on this.


Document Control Register

Hi,


Here is the forum for SharePoint technique questions, based on your post, I understand that you want to design a spreadsheet for a Document Control register.


For quick and accurate answers to your questions, it is recommended that you initial a new thread in the forum related to the Document Control register.


There are some articles about Document Control register for your reference:


http://ift.tt/1klQtMy


http://ift.tt/N60ulX


Best Regards,


Linda Li




Linda Li

TechNet Community Support



SharePoint Storage Sizing / IOPS requirements

Hello,


I have a question regarding IOPS requirements and I'm getting more and more confused.


Microsoft recommends to estimate 2000IOPS for PropertyDB and 3500 - 7000 IOPS for SearchDB. On other sites I have read that we need to calculate 2GB per GB?


What does it really mean?


If I have total 2TB of Content (sum of ContentDBs) and my Search DB is approx. 90GB in size for what I need to plan the 3500IOPS. For the Log or the DB partition or both if LOGs and DB are located on different Disks?


If I would calculate 2IOPS per GB does it mean for Search DB I need to calculate 2 x 90GB = 180IOPS??


Sorry, but I'm getting confused here?


Thank you


LINQ NullReferenceException was unhandled


Public Class Form1
Dim db As CEEDataContext
Private Sub nptItem1A_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nptItem1E.CheckedChanged, nptItem1D.CheckedChanged, nptItem1C.CheckedChanged, nptItem1B.CheckedChanged, nptItem1A.CheckedChanged
Dim sItem1 As String = " "
If nptItem1A.Checked = True Then
sItem1 = "A"
ElseIf nptItem1B.Checked = True Then
sItem1 = "B"
ElseIf nptItem1C.Checked = True Then
sItem1 = "C"
ElseIf nptItem1D.Checked = True Then
sItem1 = "D"
ElseIf nptItem1E.Checked = True Then
sItem1 = "E"
End If

'mdiSLUCEE_CBT.CheckConnection()
giAppNo = 0
giAppNo = 2084567
Dim SearchAppNo = From encodedApp In db.tblCEE_Answers _
Where encodedApp.AppNo = giAppNo


If SearchAppNo.Count > 0 Then
SearchAppNo.First.AppNo = giAppNo
SearchAppNo.First.NumItem1 = sItem1
SearchAppNo.First.LastName = gsLastName
SearchAppNo.First.FirstName = gsFirstName
SearchAppNo.First.MiddleName = gsMiddleName
db.SubmitChanges()
Else
Dim newRecord As New tblCEE_Answer With _
{.AppNo = giAppNo, _
.LastName = gsLastName, _
.FirstName = gsFirstName, _
.MiddleName = gsMiddleName, _
.NumItem1 = sItem1}

db.tblCEE_Answers.InsertOnSubmit(newRecord)
db.SubmitChanges()
End If

End Sub
End Class


I'm getting error in this line



Dim SearchAppNo = From encodedApp In db.tblCEE_Answers _
Where encodedApp.AppNo = giAppNo



Context Menu for Specific Folder using C#

Hello,


I want to add Context Menu for Specific Folder using C#. i am able to add Context Menu for all folder but i want to add for specific folder only.




Please "Mark as Answer" if this post answered your question. :)



Kalpesh Chhatrala | Software Developer | Rajkot | India



Kalpesh 's Blog



VFP Form to C#, Vb.Net Conversion Utility


Contet type not able to edit

Hi All,



I am not able to edit content type in "Quick edit" view. Can any one help me on this issue?



Regards,

Kumar.

get list item id in javascript?

Hi Hemendra,


Exactly .. i want to get current item.. so that by using id I can update my list items.


couldn't get solution from your suggested url.


Anyway thank you for your response.



get list item id in javascript?

How about this one:


http://ift.tt/1oWO26P


get list item id in javascript?

Just a small query, how are you selecting your list item? Is it a SharePoint List that you are talking about or from some webpart you are trying to perform this operation?



Geetanjali Arora | My blogs |


get list item id in javascript?

Hello,


Just try this code to get selected item ID:



var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);


http://ift.tt/1hRvwMd




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


get list item id in javascript?

You can use something like this



function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}

var ccpid = getQuerystring('ID');





Artificial intelligence can never beat natural stupidity.


get list item id in javascript?

Thank you Mikel...

get list item id in javascript?

No Prob Praveen!



Artificial intelligence can never beat natural stupidity.


get list item id in javascript?

Hi Mikel,


Thank you for your logic for getting item id.


here i couldnt understand "return qs[1]".


can I expect little explanation from you about this qs[1]?


Thanks.


get list item id in javascript?

return qs[1] means it will return the value of the ID.


This works somehow like a hashtable with a key and value pair.


qs[0] = "ID"


qs[1] = Actual value


Hope that explains it.




Artificial intelligence can never beat natural stupidity.


Scheduling a exe to run daily - How to achieve it via c#

I had a requirement to create a utility which would pull data from a Sharepoint list and generate a excel/csv file. And this utility should run once everyday.


The first part I have done (generating excel from SharePoint list). How do I schedule it to run once every day. Using a scheduled task is not an option. As they say it is not reliable. Can this be done through windows service?


Scheduling a exe to run daily - How to achieve it via c#

You can do this using "Windows Service" by putting "Timer" to run it everyday...

--------------------------------------------------------------


***If my post is answer for your query please mark as answer***


***If my answer is helpful please vote***


Tuesday, February 25, 2014

Fatch Software Inventory through WMI Connection

Hello All,


I want to fetch Software inventory List from SCCM server using WMI Connection.


Can any share it with me how can i do this ?




Regards, Ashish Patel



how to get information of employee whose salary is less than the average salary of department

Are you looking for the below?



create Table tbllessons(username varchar(100),Dep varchar(100),Salary int)
Insert into tbllessons Select 'User1','Science',600
Insert into tbllessons Select 'User2','Science',1000
Insert into tbllessons Select 'User3','Science',10
Insert into tbllessons Select 'User4','History',100
Insert into tbllessons Select 'User5','History',200

;with cte
as
(
Select *, AVG(Salary)Over(PArtition by Dep) AvgSal From tbllessons
)Select * From cte where Salary<AvgSal

Drop table tbllessons


how to get information of employee whose salary is less than the average salary of department

hi is there is any other way to do this

How to provide preview of word/pdf/ppt/img inside a metro app (c#,XAML)

In my windows 8 app i want to display the preview of pdf/docx/doc/ppt files. can anyone please suggest me the third party libraries that you know.




suresh


Using Site Content and Structure unable to move documents,pages and getting weird error message

Hi Jaya Prathap,


Would you please check whether the feature not working for specific library, specific document or all the files on all sites?


If this is happened for one library, check whether there are custom fields in the library, make sure the field works great, you can save the library as template, create a new library based on the template, delete the custom fields one by one, check the move/copy function.


If it isn’t the issue, would you please provide a screen shot of the error message when moving the file?


Thanks,




Qiao Wei

TechNet Community Support



Using Site Content and Structure unable to move documents,pages and getting weird error message

Hi,


Using Site Content and Structure unable to move documents,pages and getting weird error message


We are getting Below error:


When Moving Document items from one site to another site in the same site collection using Site content and structure(But it's working in same site,we can move documents from one library to another library)


1576|/wEWwwECuLLErw0Cy+nFYwK84baBAgK6zNqsAgLs0Le0BQK1s8uaCAL5qrm3CAKk7K6pDwKo9a0GArm+xr4NApKe9KUKAoajpK4CAqqU/2sChJXBtAIC052rYQKS+LTPAgLe+7uQAwLO0re/BwLgoaw2AojAlIMOApSO4JoNAuvW7MoKAojz2P4OAuOMt9EGAv/ns1wC64qI7gEC0LymmAcCro3lnQkCj7viwAsC8Met9QEC3a/DHALg4ZO6AQKAn8ebCALvr72DAwKm/NGmAgKN4aayCQLmmczsCgL+46qSAQKH7paCDgLouOHjDwKGuNCBCQKwuob2CQKP78n3BwLQ7vSYCALxlcvIBALRuajXAwK6/vr4AwKx8YasCQLti5igAQKay7JZAta625IFAuTy6rUKAvnC7eQKApvB3ugPAoTBua8BAoyajvgMAsGdloEJAvH+2KECAua7k9AGAv3Lzd8HAtPD3ocOAuX7hM4GAqO1g9sIAtn65sgFAuDkr9QEAt7I1KkMAryhltsIAtizx/kBAvzS7IcBAr+YhK4PAsO3rtADAvea+sADAsvc4IgKAp/1vIoMApelp3ICl+PqiwwC/KX1gwUC3fv58gIC7ZG/pwIC4cnupQgCq7mdlgYCjciR+AwC8/ue4gkC4YWJywUCs+rviAECpuyJigECkfr5rgkC08rHoQ0C+erayQUCjMqStQkCpIuKtwEC+dG5ngICoZ3/og0CspXoxwwC+pzgmwwCkoD5mAYCn/qH2AcC/N/pvAcCv5OtwAICuZquqgcC0/OFnwkC2/2wzQMCrJrO9woC69G52ggC64nunggCtLOIsQEC9LyC7gUC0ry/zgIC1ZDvgQ0C98OfMgL4kaj3CQKXhebCCwKi3bjPBQKYuojTCAKc4+fxCAKyjLfoBALVxO8SAsXSyuQLAqyvkNIPApDV5PgDAtufwJwEAu2BsoYLAs3Oqd8PAo6i+YMDAsy706oCAsLjx7kLApu3+9gKAuLnvMoIAtWywo8OAv6MjvIHAtSDhJwNArXRmL0LAraZvUcC5cGygQoCz5HN7A0C+YzY9AMCmtWQ6AUC/oHF8w4CxeTgmg8CgszujQECss22vgYCp6HBuggCkfm+FAKngqb5BgKkuIzAAQKPspKCCQLu+eDvCwKf5YrEBQKl0M3ACgKm85DvDALCu/nfCwLbwO38DgLoz5eyDQLfr9XLCwL20/eUDgL7hpr3DAKh1tfbCgL48OuNBwK4tuKaCALpgbn5CgLC4dKvBgKKlu76CwKfhKLJAQLurPTIAwLG0o+hAgKI5Y6dDALq+OOlCQKxjuuICAK8yrLHBwLcrOSSAwLoiJfQCwKKyvrtBALXkbCBCgKt4bG9BQLr6qnxCwLC2pz2DQKQ7OuZBALt7t+DDAKR47b8CAKi6pPGCQKLl4r3CQK5yfj+AwLgzYvjDwKUjerODQK7mOPTCQL9qP3qBgKYiOL9AgLA8pSaBwKay8fBDQLqw93DCgKkjpf/CwLsyquQCwKtpbGsDALMtKmxBwKPpvCmBOAFHtmBuG3iNmIT9fQ8Z1TWMpjZ122|cccccccccnncnnnnn|


How to get Guid of all form libraries

Hi Hemandra..


Thanks for the response,I am looking to relink documents using the code below...Code is working well for single form library but i have 4 to 5 form libraries for which the code should be executed..how can i get this done.I am working with Infopath forms.


protected


void btnsubmit_Click( object sender, EventArgs e)


{


if (RelinkDocuments())


{


Label3.Text =


"Success!!!" ;


}


else


{


Label3.Text =


"Failure" ;


}


}


private bool RelinkDocuments()


{


try


{


SPSite site = SPContext .Current.Site;


SPWeb spWeb = site.OpenWeb();


SPList spList = spWeb.Lists[ new Guid ( "8E023C18-DAA3-4743-81B7-E034111544BC" )];


SPDocumentLibrary doclib = ( SPDocumentLibrary )spList;


string solutionUrl = SPHttpUtility .UrlPathEncode(spWeb.Url + "/" + doclib.DocumentTemplateUrl, true );


foreach ( SPListItem spItem in doclib.Items) //loop through the list items


{


SPFieldCollection spFields = spItem.Fields;


foreach ( SPField spField in spFields) //loop through fields resetting them


{


if (spField.Type != SPFieldType .Computed &&


spField.Type !=


SPFieldType .Invalid && !spField.ReadOnlyField)


{


try


{


spItem[spField.InternalName] = spItem[spField.InternalName];


}


catch ( Exception e)


{


}


}


}


SPContentType spContentType = spList.ContentTypes[( SPContentTypeId )spItem[ "ContentTypeId" ]];


if (spContentType != null ) //try to update the item with the content type's template url which is the updated one


{


if (spContentType.DocumentTemplate.StartsWith( "http://" ) ||


spContentType.DocumentTemplate.StartsWith(


"https://" ))


{


spItem[


"TemplateUrl" ] = SPHttpUtility .UrlPathEncode(spContentType.DocumentTemplate, true );


}


else if (spContentType.DocumentTemplate.StartsWith( "/" ))


{


spItem[


"TemplateUrl" ] = SPHttpUtility .UrlPathEncode(spWeb.Site.MakeFullUrl(spContentType.DocumentTemplate), true );


}


else


{


spItem[


"TemplateUrl" ] = SPHttpUtility .UrlPathEncode(spWeb.Url + '/' + spList.RootFolder + '/' + spContentType.DocumentTemplate, true );


}


}


else //no content type found so default template url to solution Url


{


spItem[


"TemplateUrl" ] = solutionUrl;


}


spItem.Update();


}


return true ;


}


catch ( Exception ex)


{


return false ;


}


}


 


}


}