Click here to Skip to main content
12,450,568 members (51,367 online)
Rate this:
 
Please Sign up or sign in to vote.
Can anyone please give me the VB.NET or C# + SQL Server version of the code snippet?? I have never used php.

// An array containing the category ids as keys and the new positions as values
$display_order = array(
    1 => 4,
    2 => 1,
    3 => 2,
    4 => 3,
    5 => 9,
    6 => 5,
    7 => 8,
    8 => 9
);
 
$ids = implode(',', array_keys($display_order));
$sql = "UPDATE categories SET display_order = CASE id ";
foreach ($display_order as $id => $ordinal) {
    $sql .= sprintf("WHEN %d THEN %d ", $id, $ordinal);
}
$sql .= "END WHERE id IN ($ids)";
echo $sql;
Posted 9-Dec-12 22:50pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

This article is a must for your issue.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi
You can use .Net Converter to solve this problem
  Permalink  
Comments
Member 7781963 10-Dec-12 5:14am
   
Any link to the converter?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100