Search Results

Search found 7596 results on 304 pages for 'prepared statement'.

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

  • SQL syntax error in Update statement VB.net

    - by Shane Fagan
    Hi, Im getting a strange syntax error when I run this in VB SQLString = "UPDATE Login SET Password = '" + PasswordTextBox.Text + "'" SQLString += " WHERE UserName = '" + UserNameTextBox.Text + "'" The Username is checked before getting to this part and is definitly in the db. It gives an exception saying syntax error in update statement. Anyone have any ideas whats wrong?

    Read the article

  • Matlab regex if statement

    - by Dan
    I want to have matlab take user input but accept both cases of a letter. For example I have: function nothing = checkGC(gcfile) if exist(gcfile) reply = input('file exists, would you like to overwrite? [Y/N]: ', 's'); if (reply == [Yy]) display('You have chosen to overwrite!') else $ Do nothing end end The if statement obviously doesn't work, but basically I want to accept a lowercase or uppcase Y. Whats the best way to do this?

    Read the article

  • How to make this if statement in bash

    - by Selmak
    Hi, I'm having a hard time figuring out how to do this if statement. I want to do this: IF (the function has only 1 argument AND $1 is a directory (in the current folder)) OR IF (the function has 2 arguments AND $1 is NOT a directory ) THEN .... END Sorry if it's not very clear, Thanks in advance

    Read the article

  • Switch Statement Case Evaluation?

    - by TheDarkIn1978
    i would like to have cases that evaluate the expression in my switch statement. is this not possible? switch (zSpeed) { case (zSpeed > zMax): this.zSpeed = zMax; break; case (zSpeed < 0): this.zSpeed = 0; break; default: this.zSpeed = zSpeed; }

    Read the article

  • What characters are NOT escaped with a mysqli prepared statement?

    - by barfoon
    Hey everyone, I'm trying to harden some of my PHP code and use mysqli prepared statements to better validate user input and prevent injection attacks. I switched away from mysqli_real_escape_string as it does not escape % and _. However, when I create my query as a mysqli prepared statement, the same flaw is still present. The query pulls a users salt value based on their username. I'd do something similar for passwords and other lookups. Code: $db = new sitedatalayer(); if ($stmt = $db->_conn->prepare("SELECT `salt` FROM admins WHERE `username` LIKE ? LIMIT 1")) { $stmt->bind_param('s', $username); $stmt->execute(); $stmt->bind_result($salt); while ($stmt->fetch()) { printf("%s\n", $salt); } $stmt->close(); } else return false; Am I composing the statement correctly? If I am what other characters need to be examined? What other flaws are there? What is best practice for doing these types of selects? Thanks,

    Read the article

  • C# SQL Statement transformed TO LINQ how can i translate this statement to a working linq

    - by BlackTea
    I am having trouble with this I have 3 Data tables i use over and over again which are cached I would like to write a LINQ statement which would do the following is this possible? T-SQL VERSION: SELECT P.[CID],P.[AID] ,B.[AID], B.[Data], B.[Status], B.[Language] FROM MY_TABLE_1 P JOIN ( SELECT A.[AID], A.[Data], A.[Status], A.[Language] FROM MY_TABLE_2 A UNION ALL SELECT B.[AID], B.[Data], B.[Status], B.[Language] FROM MY_TABLE_3 B ) B on P.[AID] = B.[AID] WHERE B.[Language] = 'EN' OR B.[Language] = 'ANY' AND B.STATUS = 1 AND B.[Language] = 'EN' OR B.[Language] = 'ANY' AND B.STATUS = 1 Then i would like it to create a result set of the following Results: |CID|AID|DATA|STATUS|LANGUAGE

    Read the article

  • Mixing regular expression and other conditional expression in a bash if statement

    - by Tassos
    I can't get around this for quite sometime now. As I read along manuals and tutorials I'm getting more confused. I want an if statement with the following logic: if [ -n $drupal_version ] && [[ "$drupal_version" =~ DRUPAL-[6-9]-[1-9][1-9] ]]; then but I can't get it to work properly. When the script is evaluated using the "bash -x ... " script construct, works ok but when is run as a regular script my expression is not evaluated (eventhough the above condition should be met the else part is run). Could you provide any help?

    Read the article

  • Help with a simple switch statement

    - by revive
    I need to find the value of a variable and use it to add a class to a div, based on a switch statement. For example, my variable is $link and if $link has google.com IN IT at all, I need $class to equal 'google', if $link as yahoo.com IN IT at all, $class then needs to equal 'yahoo' So, I need something like this, but I'm not sure how/or if to use preg_match or something to check and see if the $link variable has the value we are looking for in it - see 'case' text below: switch ($link) { case 'IF link has Google.com in it': $class = 'google'; break; case 'IF link has Yahoo.com in it': $class = 'yahoo'; break; default: # code... break; } OR if there is a better way to do this, please let me know :D Thanks

    Read the article

  • zen of Python vs with statement - philosophical pondering

    - by NeuronQ
    I don't intend to simply waste your time, but: has it occurred to you too, while using Python's with statement that it really is contrary to the 5th line of "The Zen of Python" that goes "Flat is better than nested"? Can any enlightened Python guru share me some of their insights on this? (I always find that one more level of indentation pops up in my code every time I use with instead of f.close()... and it's not like I'm not gonna use try: ... finally: ... anyways and thus the benefits of with still elude me, even as I grow to like and understand Python more and more...)

    Read the article

  • IF statement error in tcsh

    - by kaustav datta
    Having trouble executing an IF statement through tcsh. This works FINE for me - #!/bin/bash if echo `cal|tail -6|sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' |tr -s '[:blank:]' '\n' | head -11|tail -10|tr -s '\n' ' '`|grep -w `date "+%e"` then echo "present" else echo "absent" fi This is the PROBLEM - #!/bin/tcsh if echo `cal|tail -6|sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' |tr -s '[:blank:]' '\n' | head -11|tail -10|tr -s '\n' ' '`|grep -w `date "+%e"` then echo "present" else echo "absent" endif Getting this error- if: Expression Syntax. then: Command not found. I really need this to run using "tcsh"

    Read the article

  • Does a C# using statement perform try/finally?

    - by Lirik
    Suppose that I have the following code: private void UpdateDB(QuoteDataSet dataSet, Strint tableName) { using(SQLiteConnection conn = new SQLiteConnection(_connectionString)) { conn.Open(); using (SQLiteTransaction transaction = conn.BeginTransaction()) { using (SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM " + tableName, conn)) { using (SQLiteDataAdapter sqliteAdapter = new SQLiteDataAdapter()) { sqliteAdapter.Update(dataSet, tableName); } } transaction.Commit(); } } } The C# documentation states that with a using statement the object within the scope will be disposed and I've seen several places where it's suggested that we don't need to use try/finally clause. I usually surround my connections with a try/finally, and I always close the connection in the finally clause. Given the above code, is it reasonable to assume that the connection will be closed if there is an exception?

    Read the article

  • Why is the 'if' statement considered evil?

    - by Vadim
    I just came from Simple Design and Testing Conference. In one of the session we were talking about evil keywords in programming languages. Corey Haines, who proposed the subject, was convinced that if statement is absolute evil. His alternative was to create functions with predicates. Can you please explain to me why if is evil. I understand that you can write very ugly code abusing if. But I don't believe that it's that bad.

    Read the article

  • how can i use switch statement on type-safe enum pattern

    - by Fer
    I found a goodlooking example about implementation enums in a different way. That is called type-safe enum pattern i think. I started using it but i realized that i can not use it in a switch statement. My implementation looks like the following: public sealed class MyState { private readonly string m_Name; private readonly int m_Value; public static readonly MyState PASSED= new MyState(1, "OK"); public static readonly MyState FAILED= new MyState(2, "ERROR"); private MyState(int value, string name) { m_Name = name; m_Value = value; } public override string ToString() { return m_Name; } public int GetIntValue() { return m_Value; } } What can i add to my class in order to be able to use this pattern in switch statements in C#? Thanks.

    Read the article

  • Pro/con: Initializing a variable in a conditional statement

    - by steffenj
    In C++ you can initialize a variable in an if statement, like so: if (CThing* pThing = GetThing()) { } Why would one consider this bad or good style? What are the benefits and disadvantages? Personally i like this style because it limits the scope of the pThing variable, so it can never be used accidentally when it is NULL. However, i don't like that you can't do this: if (CThing* pThing = GetThing() && pThing->IsReallySomeThing()) { } If there's a way to make the above work, please post. But if that's just not possible, i'd still like to know why. Question borrowed from here, similar topic but PHP.

    Read the article

  • Broken if statement

    - by Vladimir Nani
    Maybe I am crazy but how that could be? some == null is always false but debugger goes into if-statement body anyway. Any ideas? I have restarted visual studio I have cleaned every bin/obj folder It is not the case that i don`t understand that WindowsIdentity.GetCurrent() may return null. That was my first idea. var some = new object(); if (some == null) { throw new Exception("hi!"); } else { do(); } My code: private void GetCurrentWindowsIdentity() { var identity = WindowsIdentity.GetCurrent() if (identity == null) { throw new Exception(Errors.IdentityIsNullException); } try { if (CurrentAuthenticationWrapper.AuthenticationType == AuthenticationType.Windows) { CurrentLogin = _identity != null ? _identity.Name : string.Empty; } } catch (Exception ex) { ViewManager.ShowError(ex); } _identity = identity; }

    Read the article

  • Strange behavior of Switch Case statement in Java

    - by supernova
    I understand that Java switch case are designed this way but why is this behavior in Java int x = 1; switch(x){ case 1: System.out.println(1); case 2: System.out.println(2); case 3: System.out.println(3); default: System.out.println("default"); } output : 1 2 3 default My question is why case 2 and 3 are executed? I know I omitted break statement but x was never 2 or 3 but case 2 and case 3 still executes?

    Read the article

  • JQuery if/else statement matching a wildcard css name

    - by Neokoenig
    Hi All, I'm trying to write an if/else statement in jQuery which can change an elements class by matching 'IN' or 'OUT' (in this case). I.e, I have several Divs with class='IN-something' OR class='OUT-something'. The below would work if I new the exact CSS class, but all I'll know is whether it contains 'IN' or 'OUT'. So like this, but works: if ($(jRow).hasClass('IN-*')) {jRow.attr( "class", "OUT-foo" );} else {jRow.attr( "class", "IN-foo");} Ideas? Thanks!

    Read the article

  • python's `with` statement

    - by Prestel Nué
    Hi there, seems like I do not understand something with---the python with statement. Consider this class: class test(object): def __enter__(self): pass def __exit__(self, *ignored): pass now, when using it with with, like in with test() as michael: print repr(michael) I would expect some output like <test instance at memore blah>. But I get None. Something wrong here? Any suggestions would help. (I am using Python 2.6.6.) EDIT: Thanks to ephement for pointing me to the documentation. The __enter__ method should read def __enter__(self): return self

    Read the article

  • Entering If Statement Despite Not Meeting Condition

    - by msmf14
    This is a specific problem, but I can't seem to figure out what is wrong. else if (X == 2) //move left { if (Level[X-1][Y] == 0); { cout << Level[X-1][Y] << "\n"; cout << "\n MOVING LEFT from RIGHT\n"; //PROBLEM IS HERE Level[X][Y] = 1; // block it X = X - 1; moved = 1; } } What I am doing is I am checking if Level[X-1][Y] is 1, indicating a column, so I can not move my player there. However for some reason, despite it being 1 and not 0 (as indicated by the output), the IF statement is still accessed. Any help will be appreciated.

    Read the article

  • “if” statement vs OO Design - 2

    - by hilal
    I encountered similar problem “if” statement vs OO Design - 1 but it is slightly different. Here is the problem that open the popup (different objects/popups) onValueChange of listbox Popup1 p1; // different objects Popup2 p2; // different objects Popup3 p3; ... listbox.add("p1"); listbox.add("p2"); listbox.add("p3"); ... listbox.addChangeHandler() { if(getSelectedItem().equals("p1")){ p1 = new Popup1(); p1.show(); } else if() {...} .... } I don't want to write "if" that if p1 then p1 = new Popup1(); p1.center(); How I can handle this situation? Any design-pattern? Here is my solution but it is so costly map() { map.put("p1", new Popup1()); map.put("p2", new Popup2()); map.put("p3", new Popup3()); } onValueChange() { map.get(selectedItem).show(); } One drawback is initialization all the popups. but it is require only when valueChange

    Read the article

  • Simply if Statement for checking co-ordinate square.

    - by JonB
    I have an UIImageView and taking the raw touch input. I need to check if a touch is within a certain set of squares. At the moment... I have this if statement.... if(46 < touchedAt.x && touchedAt.x < 124 && 18 < touchedAt.y && touchedAt.y < 75) but I have tried to simplify it to this one... if(46 < touchedAt.x < 124 && 18 < touchedAt.y < 75) It didn't work. Is it possible to simplify like this or am I stuck with the slightly lengthier version at the top? Is there a reason why the types of comparisons in the bottom if don't work? Many Thanks.

    Read the article

  • Help with MySQL Query using CASE statement

    - by hairdresser-101
    I am trying to group a number of customers together based on their "Head Office" or "Parent" location. THis works ok except for a flaw which I didn't forsee when I was developing my system... For customers that did not have a "Parent" (standalone business) I defaulted the parent_id to 0. Therefore, my data would look like this: id parent_id customer 1 0 CustName#1 2 4 CustName#2 - Melbourne 3 4 CustName#2 - Sydney 4 0 CustName#2 (Head Office) What I want to do is Group my results together so that I have one row for CustName#1 and one row for CustName#2 BUT my problem is that there is no parent record for parent_id=0 and these rows are being excluded when using an inner join. I've tried using a case statement but that is not working either (parents are still being ignored) Any help would be greatly appreciated. Here is my query (My CASE is basically trying to get the business_name from the customer table based on the parent_id EXCEPT when the parent_id = 0, THEN just use the customer_name that is listed in the job_summary table): SELECT js.month_of_year, (CASE js.parent_id WHEN 0 THEN js.customer_name ELSE c.business_name END) as customer, SUM(js.jobs), SUM(js.total_cost), sum(js.total_sell) FROM JOB_SUMMARY js INNER JOIN customer c on js.parent_id=c.id group by js.month_of_year, (CASE c.parent_id WHEN 0 THEN js.customer_name ELSE c.business_name END) ORDER BY `customer` ASC

    Read the article

  • if/else statement in a function: using onclick as a switch

    - by Aurora Schmidt
    I have looked for solutions to this on google for what seems like an eternity, but I can't seem to formulate my search correctly, or nobody has posted the code I'm looking for earlier. I am currently trying to make a function that will modify one or several margins of a div element. I want to use an if/else statement within the function, so that the onclick event will switch between the two conditions. This is what I have been working on so far; function facebookToggle() { if($('#facebooktab').style.margin-left == "-250px";) { document.getElementById("facebooktab").style.marginLeft="0px"; } else { document.getElementById("facebooktab").style.marginLeft="-250px"; } } I have tried twisting it around a little, like switching between "marginLeft" and "margin-left", to see if I was just using the wrong terms.. I'm starting to wonder if it might not be possible to combine jQuery and regular javascript? I don't know.. It's all just guesses on my part at this point. Anyway, I have a div, which is now positioned (fixed) so almost all of it is hidden outside the borders of the browser. I want the margin to change onclick so that it will be fully shown on the page. And when it is shown, I want to be able to hide it again by clicking it. I might be approaching this in the wrong way, but I really hope someone can help me out, or even tell me another way to get the same results. Thank you for any help you can give me. You can see it in action at: http://www.torucon.no/test/ (EDIT: By the way, I am a complete javascript novice, I have no experience with javascript prior to this experiment. Please don't be too harsh, as I am aware I probably made some really stupid mistakes in this short code.) EDITED CODE: function facebookToggle() { if($('#facebooktab').css('margin-left', '-250px') { $('#facebooktab').css('margin-left', '0px'); } else { $('#facebooktab').css('margin-left', '-250px'); } }

    Read the article

  • Java - If statement with String comparison fails

    - by Andrea
    I really don't know why the if statement below is not executing: if (s == "/quit") { System.out.println("quitted"); } Below is the whole class. It is probably a really stupid logic problem but I have been pulling my hair out over here not being able to figure this out. Thanks for looking :) class TextParser extends Thread { public void run() { while (true) { for(int i = 0; i < connectionList.size(); i++) { try { System.out.println("reading " + i); Connection c = connectionList.elementAt(i); Thread.sleep(200); System.out.println("reading " + i); String s = ""; if (c.in.ready() == true) { s = c.in.readLine(); //System.out.println(i + "> "+ s); if (s == "/quit") { System.out.println("quitted"); } if(! s.equals("")) { for(int j = 0; j < connectionList.size(); j++) { Connection c2 = connectionList.elementAt(j); c2.out.println(s); } } } } catch(Exception e){ System.out.println("reading error"); } } } } }

    Read the article

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