Search Results

Search found 28627 results on 1146 pages for 'case statement'.

Page 2/1146 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Linq to SQL case sensitivity causing problems

    - by Roger Lipscombe
    I've seen this question, but that's asking for case-insensitive comparisons when the database is case-sensitive. I'm having a problem with the exact opposite. I'm using SQL Server 2005, my database collation is set to Latin1_General_CI_AS. I've got a table, "User", like this: CREATE TABLE [dbo].[User] ( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](max) NOT NULL, CONSTRAINT [PK_Example] PRIMARY KEY CLUSTERED ( [Id] ASC ) ) And I'm using the following code to populate it: string[] names = new[] { "Bob", "bob", "BoB" }; using (MyDataContext dataContext = new AppCompatDataContext()) { foreach (var name in names) { string s = name; if (dataContext.Users.SingleOrDefault(u => u.Name == s) == null) dataContext.Users.InsertOnSubmit(new User { Name = name }); } dataContext.SubmitChanges(); } When I run this the first time, I end up with "Bob", "bob" and "BoB" in the table. When I run it again, I get an InvalidOperationException: "Sequence contains more than one element", because the query against the database returns all 3 rows, and... SELECT * FROM [User] WHERE Name = 'bob' ... is case-insensitive. That is: when I'm inserting rows, Linq to SQL appears to use C# case-sensitive comparisons. When I query later, Linq to SQL uses SQL Server case-insensitive comparisons. I'd like the initial insert to use case-insensitive comparisons, but when I change the code as follows... if (dataContext.Users.SingleOrDefault(u => u.Name.Equals(s, StringComparison.InvariantCultureIgnoreCase) ) == null) ... I get a NotSupportedException: "Method 'Boolean Equals(System.String, System.StringComparison)' has no supported translation to SQL." Question: how do I get the initial insert to be case-insensitive or, more precisely, match the collation of the column in the database? Update: This doesn't appear to be my problem. My problem appears to be that SingleOrDefault doesn't actually look at the pending inserts at all.

    Read the article

  • What if(event) statement means in JavaScript?

    - by j flo
    I'm rather new to JavaScript and programming in general so I am pretty much only used to seeing if statements that have some kind of comparison operator like, if (x < 10) or if(myBool). I have seen an if statement checking against an event, but I don't understand what or why the event is being checked like that. What's the semantic meaning behind that check or comparison? Here is the code in question: if(event){ event.preventDefault(); }

    Read the article

  • Newbie worried about CASE tool.

    - by Jason Evans
    Hi there. I'm looking for some guidance on CASE tools and whether my concerns are valid. Recently I was in a meeting between my employer and an external software company which have a CASE tool currently in beta. They demonstrated this tool to us, showing how you build a UML model in Enterprise Architect (or something like it) and then, through their tool, that UML model is transformed into a Visual Studio project, with C# files, stored procedures for SQL Server, code for the data layer, WCF stuff, logging code and allsorts. Now, admittedly, I don't see the point in this, as in I'm not convinced it will save that much time (plus it feels like overkill). The tool authors said that a trial of the tool at another company had saved a team there 5 weeks of development time (from 6 weeks down to about 1 week) using this tool. I find the accuracy of that estimate hard to believe. My main concern is whether using this tool is going slow down my productivity. For example - Say I have a UML model which I built a VS solution from. Now, I want to rename a class method to something else; will this mean having to update the UML model first and then rebuilding the code? Is this how case tools normally work? Something I will need to check with the authors is the structure of the generated VS solution. I like the Domain Driven Design way of project structure - Infrstructure, Services, Model, etc. I doubt very much this tool will do that. Also, I've been playing around with Entity Framework Code First and think it's a great way to build the data model. I have nice repositories, unit of work classes and other design patterns that work well with EF. I have data anootations and stuff like that working great. By not having EF (the CASE tool uses it's own data layer code) I'm concerned that this tool's data layer code might not be a nice to integrate in the UoW pattern, repositories, etc. This I will need to verify when I get a closer look at the generated code. What are other people's experiences with CASE tools? Am I being paranoid about nothing? Am I being unfair - are my negativities unfounded? EDIT: I like to use TDD/BDD for building my code, and using a CASE tool looks like it will make this difficult. Again, any feedback on this would be great. Cheers. Jas.

    Read the article

  • Is my use case diagram correct?

    - by Dummy Derp
    NOTE: I am self studying UML so I have nobody to verify my diagrams and hence I am posting here, so please bear with me. This is the problem I got from some PDF available on Google that simply had the following problem statement: Problem Statement: A library contains books and journals. The task is to develop a computer system for borrowing books. In order to borrow a book the borrower must be a member of the library. There is a limit on the number of books that can be borrowed by each member of the library. The library may have several copies of a given book. It is possible to reserve a book. Some books are for short term loans only. Other books may be borrowed for 3 weeks. Users can extend the loans. 1. Draw a use case diagram for a library. 2. Give a use case description for two use cases: • Borrow copy of book • Extend loan Diagram: Use case description: 1. Borrow a copy of the book: If the person wishes to borrow a book from Derpville Public Library, he/she must be a member of the library in which case they will be allowed to issue a certain number of books. If the person is not a member, the book will not be issued to them for taking away, rather they will have to sit and read in the library. 2. Extending loan: Some books will be lent for 3 weeks while others will be lent for more than 3 weeks in which case the person borrowing has to come to the library and get the date extended. There is a limit on how much the user can extend the date of a particular book.

    Read the article

  • If statement is ignored

    - by user2898120
    I am making a simple matchmaker as a learning project in JAVA. My program so far just asks a few questions, but I wanted to do gender specific questions, so I asked for their sex (m or f) and then attempted to add a message that only showed if sex was m. The dialog should say "well done, you are male!". Else it restarts method. Every time, no matter what I type it restarts the program. Here is my code: import javax.swing.JOptionPane; public class Main { public static void main(String[] args){ setVars(); } public static void setVars(){ String name = JOptionPane.showInputDialog(null, "What is your name?"); String sAge = JOptionPane.showInputDialog(null, "What is your age?"); String sex = JOptionPane.showInputDialog(null, "What is your sex?\n(Enter m or f)"); if (sex == "m"){ JOptionPane.showMessageDialog(null, "Well done, you are male.\nKeep Going!"); } int age = Integer.parseInt(sAge); String chars = JOptionPane.showInputDialog(null, "Name three charectaristics"); } }

    Read the article

  • Making a switch statement in C with an array?

    - by Eric
    I am trying to make a switch statement that takes in a word into an array and then throws each letter through a switch statement and allocates a point to each letter depending on which letter it is and giving a final point value for the word, and I can't seem to get the array part right. Any help would be appreciated! int main(){ int letter_points = 0; char word[7]; int word_length = 7; int i; printf("Enter a Word\n"); scanf("%s", word); for(i = 0; i < word_length; i++){ switch(word){ //1 point case 'A': case 'E': case 'I': case 'L': case 'N': case 'O': case 'R': case 'S': case 'T': case 'U': letter_points++; break; //2 points case 'D': case 'G': letter_points += 2; break; //3 points case 'B': case 'C': case 'M': case 'P': letter_points += 3; break; //4 points case 'F': case 'H': case 'V': case 'W': case 'Y': letter_points += 4; break; //5 points case 'K': letter_points += 5; break; //8 points case 'J': case 'X': letter_points += 8; break; //10 points case 'Q': case 'Z': letter_points += 10; break; } } printf("%d\n", letter_points); return; }

    Read the article

  • Why Switch/Case and not If/Else If?

    - by OB OB
    This question in mainly pointed at C/C++, but I guess other languages are relevant as well. I can't understand why is switch/case still being used instead of if/else if. It seems to me much like using goto's, and results in the same sort of messy code, while the same results could be acheived with if/else if's in a much more organized manner. Still, I see these blocks around quite often. A common place to find them is near a message-loop (WndProc...), whereas these are among the places when they raise the heaviest havoc: variables are shared along the entire block, even when not propriate (and can't be initialized inside it). Extra attention has to be put on not dropping break's, and so on... Personally, I avoid using them, and I wonder wether I'm missing something? Are they more efficient than if/else's? Are they carried on by tradition?

    Read the article

  • How to checkout a case sensitive SVN source code branch to a case insensitive system?

    - by gagneet
    I am working on a Macbook system , which is formatted as a case insensitive system. The issue is that, I need to check out a SVN branch which has some case sensitive files in it. Example: inbuilt-file.c InBuilt-File.c How do I checkout this branch when both the files are in the same folder? When I try and checkout, it gives me an error stating that an unversioned file of the name already exists.

    Read the article

  • Custom Silent HTPC Uses Entire Case as a Heatsink

    - by Jason Fitzpatrick
    This silent media center PC dissipates heat in a rather clever way; the entire back of the case is one giant heatsink. Courtesy of computer enthusiast and tinker DeFex, the build isn’t just silent but quite eye catching too. He used a combination of one massive heatsink, custom brackets, acrylic, and bicycle spokes to create a sleek case that looks as much like a computer-inspired work of art as it does a media center computer. Hit up the link below to check out the build gallery and see how he mated the CPU to the heatsink-body with a custom milled aluminum bridge. Heatsink HTPC [via Hack A Day] Secure Yourself by Using Two-Step Verification on These 16 Web Services How to Fix a Stuck Pixel on an LCD Monitor How to Factory Reset Your Android Phone or Tablet When It Won’t Boot

    Read the article

  • How is a switch statement better than a series of if statements? [closed]

    - by user1276078
    Possible Duplicate: Should I use switch statements or long if…else chains? I'm working on a small program that will conduct an Insertion Sort. A number will be inputted through the keyboard and stored in a variable I called "num." I've decided to use a switch statement in order to obtain the number inputted. switch( e.getKeyCode() ) { case KeyEvent.VK_0: num = 0; break; case KeyEvent.VK_1: num = 1; break; case KeyEvent.VK_2: num = 2; break; case KeyEvent.VK_3: num = 3; break; case KeyEvent.VK_4: num = 4; break; case KeyEvent.VK_5: num = 5; break; case KeyEvent.VK_6: num = 6; break; case KeyEvent.VK_7: num = 7; break; case KeyEvent.VK_8: num = 8; break; case KeyEvent.VK_9: num = 9; break; } I realized one other course of action could have been to use a set of if statements. if( e.getKeyCode() == KeyEvent.VK_0 ) num = 0; else if( e.getKeyCode() == KeyEvent.VK_1 ) num = 1; etc. for every number up until 9. I then wondered what the essential difference is between a switch statement and a series of if statements. I know it saves space and time to write, but it's not that much. So, my question is, aside from the space, does a switch statement differ from a series of if statments in any way? Is it faster, less error-prone, etc.? This question really doesn't affect my code that much. I was just wondering. Also, this question pertains to the JAVA language, not any other programming language.

    Read the article

  • Problem with a "Select Case"

    - by Nimrod
    i wrote the following section below. when debugging, i see that i enter the first Case okay. my problem is with the second Case - it does not enter it and goes to the error messege. what do i do wrong? Select Case Data_Rate Case "1", "2", "5.5", "11", "6", "9", "12", "18", "24", "36", "48", "54" a = Data_Rate Select Case Date_Rate Case "1" b = 2 Case "2", "5.5", "11" b = 1 Case Else: MsgBox ("ERROR - Data_Rate") End Select Case "0", "1", "2", "3", "4", "5", "6", "7" a = 3 Case Else: MsgBox ("ERROR - Data_Rate") End Select

    Read the article

  • Mysql CASE - WHEN - THEN - returning wrong data type (blob)

    - by Jack
    Hi there. Im creating customizable product attributes in a web store - each attribute can have different type of data, each data type is stored in a separate column using corresponding mysql datatype. I Have a query like: SELECT products.id AS id, products.sku AS sku, products.name AS name, products.url_key AS url_key, attributes.name AS attribute, CASE WHEN `attribute_types`.`type` = 'text' THEN product_attribute_values.value_text WHEN `attribute_types`.`type` = 'float' THEN product_attribute_values.value_float WHEN `attribute_types`.`type` = 'price' THEN product_attribute_values.value_float WHEN `attribute_types`.`type` = 'integer' THEN product_attribute_values.value_integer WHEN `attribute_types`.`type` = 'multiple' THEN product_attribute_values.value_text WHEN `attribute_types`.`type` = 'dropdown' THEN product_attribute_values.value_text WHEN `attribute_types`.`type` = 'date' THEN product_attribute_values.value_date WHEN `attribute_types`.`type` = 'textarea' THEN product_attribute_values.value_textarea END as value from (...) Now, the problem is that when attribute_types.type equals to ?some-type? i want it to return a value as it's stored in product_attribute_values table. Currently I get BLOb every time. Should I use type-casting or there's some behind-the-scene magic that I dont know about, OR maybe there's some better alternative ?

    Read the article

  • git mv and only change case of directory

    - by oschrenk
    While I found similar question I didn't find an answer to my problem When I try to rename the directory from FOO to foo via git mv FOO foo I get fatal: renaming 'FOO' failed: Invalid argument OK. So I try git mv FOO foo2 && git mv foo2 foo But when I try to commit via git commit . I get # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # foo nothing added to commit but untracked files present (use "git add" to track) When I add the directory via git add foo nothing changes and git commit . gives me the same message again. What am I doing wrong? I thought I'm using a case-sensitive system (OSX) why can't I simply rename the directory?

    Read the article

  • Use Case Actors - Primary versus Secondary

    - by Dave Burke
    The Unified Modeling Language (UML1) defines an Actor (from UseCases) as: An actor specifies a role played by a user or any other system that interacts with the subject. In Alistair Cockburn’s book “Writing Effective Use Cases” (2) Actors are further defined as follows: Primary Actor: The primary actor of a use case is the stakeholder that calls on the system to deliver one of its services. It has a goal with respect to the system – one that can be satisfied by its operation. The primary actor is often, but not always, the actor who triggers the use case. Supporting Actors: A supporting actor in a use case in an external actor that provides a service to the system under design. It might be a high-speed printer, a web service, or humans that have to do some research and get back to us. In a 2006 article (3) Cockburn refined the definitions slightly to read: Primary Actors: The Actor(s) using the system to achieve a goal. The Use Case documents the interactions between the system and the actors to achieve the goal of the primary actor. Secondary Actors: Actors that the system needs assistance from to achieve the primary actor’s goal. Finally, the Oracle Unified Method (OUM) concurs with the UML definition of Actors, along with Cockburn’s refinement, but OUM also includes the following: Secondary actors may or may not have goals that they expect to be satisfied by the use case, the primary actor always has a goal, and the use case exists to satisfy the primary actor. Now that we are on the same “page”, let’s consider two examples: A bank loan officer wants to review a loan application from a customer, and part of the process involves a real-time credit rating check. Use Case Name: Review Loan Application Primary Actor: Loan Officer Secondary Actors: Credit Rating System A Human Resources manager wants to change the job code of an employee, and as part of the process, automatically notify several other departments within the company of the change. Use Case Name: Maintain Job Code Primary Actor: Human Resources Manager Secondary Actors: None The first example is quite straight forward; we need to define the Secondary Actor because without the “Credit Rating System” we cannot successfully complete the Use Case. In other words, the goal of the Primary Actor is to successfully complete the Loan Application, but they need the explicit “help” of the Secondary Actor (Credit Rating System) to achieve this goal. The second example is where people sometimes get confused. Within OUM we would not include the “other departments” as Secondary Actors and therefore not include them on the Use Case diagram for the following reasons: The other departments are not required for the successful completion of the Use Case We are not expecting any response from the other departments (at least within the bounds of the Use Case under discussion) Having said that, within the detail of the Use Case Specification Main Success Scenario, we would include something like: “The system sends a notification to the related department heads (ref. Business Rule BR101)” Now let’s consider one final example. A Procurement Manager wants to place a “bid” for some goods using an On-Line Trading Community (B2B version of eBay) Use Case Name: Create Bid Primary Actor: Procurement Manager Secondary Actors: On-Line Trading Community You might wonder why the Trading Community is listed as a Secondary Actor, i.e. if all we are going to do is place a bid for a specific quantity of goods at a given price and send that off to the Trading Community, then why would the Trading Community need to “assist” in that Use Case? Well, once again, it comes back to the “User Experience” and how we want to optimize that when we think about our Use Case, and ultimately, when the developer comes to assembling some code. In this final example, the Procurement Manager cannot successfully complete the “Create Bid” Use Case until they receive an affirmative confirmation back from the Trading Community that the Bid has been accepted. Therefore, the Trading Community must become a Secondary Actor and be referenced both on the Use Case diagram and Use Case Specification. Any astute readers who are wondering about the “single sitting” rule will have to wait for a follow-up Blog entry to find out how that consideration can be factored in!!! Happy Use Case writing! (1) OMG Unified Modeling LanguageTM (OMG UML), Superstructure Version 2.4.1 (2) Cockburn, A, 2000, Writing Effective Use Case, Addison-Wesley Professional; Edition 1 (3) Cockburn, A, 2006 “Use Case fundamentals” viewed 20th March 2012, http://alistair.cockburn.us/Use+case+fundamentals

    Read the article

  • Behavior-Driven Development / Use case diagram

    - by Mik378
    Regarding growing of Behavior-Driven Development imposing acceptance testing, are use cases diagram useful or do they lead to an "over-documentation"? Indeed, acceptance tests representing specifications by example, as use cases promote despite of a more generic manner (since cases, not scenarios), aren't they too similar to treat them both at the time of a newly created project? From this link, one opinion is: Another realization I had is that if you do UseCases and automated AcceptanceTests you are essentially doubling your work. There is duplication between the UseCases and the AcceptanceTests. I think there is a good case to be made that UserStories + AcceptanceTests are more efficient way to work when compared to UseCases + AcceptanceTests. What to think about?

    Read the article

  • How to show an "or includes" relationship - UML Use case diagram

    - by TheNewBlack
    I haven't come across this issue before and can't find it in my Schaum's Outline UML book and was wondering if someone here could help. I'm making a use case diagram for e-commerce, and in it I want to describe that in order to add a book to your shopping basket, you have to either search products (using the websites search engine) or browse products (using navigation). But the thing is that it can be either one, and not both. Is there a way to show that adding a product to the basket needs to include either this or that? Because otherwise it would look like it needs to include both. Or should I join the two use cases (search products and browse products) into one?

    Read the article

  • How to create a use case diagram for board game played on PC

    - by user970696
    I'm struggling with a task as I was given to practice UML and use cases. The problem is that I should model computer version of a board game so I am unsure about a few things. obviously it does not matter if you play against the PC or another player, the actions are the same. The game is simply like tic tac toe. E.g. Actor Player ---(Place a diamond)-----include----(Check for a row)---include--(Swap players) But the game is played on the PC, so is Check for row really a use case? And the same with Swap players? Because the system would do that. On the other hand, if it was not, how could I continue?

    Read the article

  • Why is there never any controversy regarding the switch statement? [closed]

    - by Nick Rosencrantz
    We all know that the gotostatement should only be used on very rare occasions if at all. It has been discouraged to use the goto statement countless places countless times. But why it there never anything like that about the switch statement? I can understand the position that the switch statement should always be avoided since anything with switch can always be expressed by if...else... which is also more readable and the syntax of the switch statement if difficult to remember. Do you agree? What are the arguments in favor of keeping the 'switch` statement? It can also be difficult to use if what you're testing changes from say an integer to an object, then C++ or Java won't be able to perform the switch and neither C can perform switch on something like a struct or a union. And the technique of fall-through is so very rarely used that I wonder why it was never presented any regret of having switch at all? The only place I know where it is best practice is GUI code and even that switch is probably better coded in a more object-oriented way.

    Read the article

  • php switch statement error on int = 0

    - by Jagdeep Singh
    I am having a problem in php switch case. When i set $number=0 it should run very first case but here this code returns 10-20K that is in second case. I checked comparison operators, tested them in if else case they return correct values but here first case do not run on $number=0 Why is this happening ? php consider 0 as false or something wrong in code ? Link to codepad paste http://codepad.org/2glDh39K also here is the code <?php $number = 0; switch ($number) { case ($number <= 10000): echo "0-10K"; break; case ($number > 10000 && $number <= 20000): echo "10-20K"; break; case ($number > 20000 && $number <= 30000): echo "20-30K"; break; case ($number > 30000 && $number <= 40000): echo "30-40K"; break; case ($number > 40000 && $number <= 50000): echo "40-50K"; break; case ($number > 50000 && $number <= 60000): echo "50-60K"; break; case ($number > 60000 && $number <= 70000): echo "60-70K"; break; case ($number > 70000 && $number <= 80000): echo "70-80K"; break; case ($number > 80000 && $number <= 90000): echo "80-90K"; break; case ($number > 90000): echo "90K+"; break; default: //default echo "N/A"; break; } ?>

    Read the article

  • Case Management API by Koen van Dijk

    - by JuergenKress
    Case Management is a new addition to Oracle BPM in release 11.1.1.1.7 (PS6). This new release contains the Case Management engine, see blog Léon at  http://leonsmiers.blogspot.nl/ for more details.  However, currently this release does not contain a case portal. The case management API's, just like the already existing Oracle BPM API's, help in developing a portal page with relative ease. This blog will use some real life examples from the EURent casemanagement application and portal application developed by Oracle. The Oracle BPM Case Management API is a Java Based API that enables developers to programmatically access the new Case Management functionalities. It is an elaborate API that can access all the functionalities of Oracle Case Management. I will describe two of those functionalities in this blog: retrieving case data as DOM (http://www.w3.org/DOM/) and attaching a document to a case. Libraries First of all when creating a Case Management project you will need to attach the following libraries: These contain all the classes that are in the Case Management API. Service client To do anything with the BPM CaseManagement API in general it is necessary to create a CaseManagementServiceClient Object. The Case Management service client is the central piece of the Case Management API. It can be used to retrieve two different types of services. The first is the case stream service and the case service. The case stream service contains functionality to upload and download documents to and from a case. The second one is the CaseService. This service contains all the other functionality acting upon a case including but not limited to: Read the complete article here. SOA & BPM Partner Community For regular information on Oracle SOA Suite become a member in the SOA & BPM Partner Community for registration please visit www.oracle.com/goto/emea/soa (OPN account required) If you need support with your account please contact the Oracle Partner Business Center. Blog Twitter LinkedIn Facebook Wiki Technorati Tags: ACM API,adaptive Case Management,BPM,SOA Community,Oracle SOA,Oracle BPM,Community,OPN,Jürgen Kress

    Read the article

  • SQL orderby / case issue: orderdirection fail

    - by Joris
    I got a stored procedure that delivers a table of students, and it needs to order by surname, name etc... it also needs to sort ascending, descending, depending on the parameter @orderby... code: ORDER BY CASE WHEN @orderby = 'studentkey' THEN Studentkey END ASC, CASE WHEN @orderby = 'studentkey' and @desc = 1 THEN Studentkey END DESC, CASE WHEN @orderby = 'initials' THEN Initials END ASC, CASE WHEN @orderby = 'initials' and @desc = 1 THEN Initials END DESC, CASE WHEN @orderby = 'firstname' THEN Firstname END ASC, CASE WHEN @orderby = 'firstname' and @desc = 1 THEN Firstname END DESC, CASE WHEN @orderby = 'nickname' THEN Nickname END ASC, CASE WHEN @orderby = 'nickname' and @desc = 1 THEN Nickname END DESC, CASE WHEN @orderby = 'insertion' THEN Insertion END ASC, CASE WHEN @orderby = 'insertion' and @desc = 1 THEN Insertion END DESC, CASE WHEN @orderby = 'surname' THEN Surname END ASC, CASE WHEN @orderby = 'surname' and @desc = 1 THEN Surname END DESC NED There is a difference in output between @desc = 1 and @desc = 0, but not what i desire... Does anyone have a solution?

    Read the article

  • Case in-sensitivity for Apache httpd Location directive

    - by user57178
    I am working with a solution that requires the usage of mod_proxy_balancer and an application server that both ignores case and mixes different case combinations in URLs found in generated content. The configuration works, however I have now a new requirement that causes problems. I should be able to create a location directive (as per http://httpd.apache.org/docs/current/mod/core.html#location ) and have the URL-path interpret in case insensitive mode. This requirement comes from the need to add authentication directives to the location. As you might guess, users (or the application in question) changing one letter to capital circumvents the protection instantly. The httpd runs on Unix platform so every configuration directive is apparently case sensitive by default. Should the regular expressions in the Location directive work in this case? Could someone please show me an example of such configuration that should work? In case a regular expression can not be forced to work case insensitively, what part of httpd's source code should I go around modifying?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >