Search Results

Search found 49435 results on 1978 pages for 'query string'.

Page 22/1978 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • C#: split a string into runs of characters, numbers and delimited strings and process it

    - by nrkn
    OK my regex is a bit rusty and I've been struggling with this particular problem... I need to split and process a string containing any number of the following, in any order: Chars (lowercase letters only) Quote delimited strings Ints The strings are pretty weird (I don't have control over them). When there's more than one number in a row in the string they're seperated by a comma. They need to be processed in the same order that they appeared in the original string. For example, a string might look like: abc20a"Hi""OK"100,20b With this particular string the resulting call stack would look a bit like: ProcessLetters( new[] { 'a', 'b', 'c' } ); ProcessInts( 20 ); ProcessLetters( 'a' ); ProcessStrings( new[] { "Hi", "OK" } ); ProcessInts( new[] { 100, 20 } ); ProcessLetters( 'b' ); What I could do is treat it a bit like CSV, where you build tokens by processing the characters one at a time, but I think it could be more easily done with a regex?

    Read the article

  • Error using iif in ms access query

    - by naveen
    I am trying to fire this query in MS Access SELECT file_number, IIF(invoice_type='Spent on Coding',SUM(CINT(invoice_amount)), 0) as CodingExpense FROM invoice GROUP BY file_number I am getting this error Error in list of function arguments: '=' not recognized. Unable to parse query text. I tried replacing IIF with SWITCH to no avail. What's wrong with my query and how to correct this?

    Read the article

  • how to dissect string values

    - by nhoyti
    how can i dissect or retrieve string values Here's the sample code that im working on now private void SplitStrings() { List<string> listvalues = new List<string>(); listvalues = (List<string>)Session["mylist"]; string[] strvalues = listvalues.ToArray(); for (int x = 0; x < strvalues.Length; x++) { } } now that i'am able to retrieve List values in my session, how can i separately get the values of each list using foreach or for statement?

    Read the article

  • How to evaluate the string in ruby if the string contains ruby command?

    - by Arun
    In my case, I was storing the sql query in my database as text. I am showing you one record which is present in my database Query.all :id => 1, :sql => "select * from user where id = #{params[:id]}" str = Query.first Now 'str' has value "select * from user where id = #{params[:id]}" Here, I want to parsed the string like If my params[:id] is 1 then "select * from user where id = 1" I used eval(str). Is this correct?

    Read the article

  • Problem with mysql query in paging

    - by jasmine
    I have a very simple paging and mysql query. Im not sure that my query is right: $perPage =4; $page= (isset($GET['page']) && is_numeric($GET['page'])) ? $_GET['page'] : 1; $start = ($page * $perPage ) - $perPage ; if (is_numeric($_GET['cID'])){$cid = $_GET['cID'];} $totalCount = sprintf("SELECT COUNT(*) as 'Total' FROM content WHERE catID = %d", $cid ) ; $count = mysql_query($totalCount); $rowCount = mysql_fetch_array($count); $sql = sprintf("SELECT id, title, abstract, content_image FROM content WHERE catID = %d ORDER BY id DESC LIMIT %d, %d", $cid, $start, $perPage ); $query = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($query)){ echo $row['id'].' : '. $row['title'] .'<br>'; } with /categories.php?cID=1&page=2 and /categories.php?cID=1&page=1 The output is: 95 : titlev 94 : titlex 93 : titlec 92 : titleb and not changed. What is wrong in my query? Thanks in advance

    Read the article

  • php codeigniter MySQL search query

    - by kalafun
    I want to create a search query on MySQL database that will consist of 5 different strings typed in from user. I want to query 5 different table columns with these strings. When I for example have input fields like: first name, last name, address, post number, city. How should I query the database that I dont always get all the rows. My query is something like this: SELECT user_id, username from users where a like %?% AND b like %?% AND c like %?% AND d like %?% AND e like %?%; When I exchange the AND for OR I always get all the results which makes sense, and when I use AND I get only the exact matches... Is there any function or statement that would help me with this?

    Read the article

  • seperated mysql statement query in php

    - by stone
    So, I can run the following statements from within mysql itself successfully. SET @fname = 'point1'; SELECT * FROM country WHERE name=@fname;` But when I try to pass the query through php like this and run it, I get an error on the second line $query = "SET @fname = 'point1';"; $query .= "SELECT * FROM country WHERE name=@fname;";

    Read the article

  • Help with SQL query

    - by user154301
    Hello, I have list of DateTime values, and for each value I need to fetch something from the database. I would like to do this with one query. I know it's possible to pass a table (list) to the stored procedure, but Im not sure how to write the query itself. Let's say I have the following table: CREATE TABLE Shows( ShowId [int] NOT NULL, StartTime DateTime NOT NULL, EndTime DateTime NOT NULL ) and an array of dates DECLARE @myDateArray MyCustomDateArrayType Now, if I were fetching a single item, I would write a query like this: SELECT * FROM Shows WHERE StartTime > @ArrayItem and @ArrayItem < EndTime where @ArrayItem is an item from @myDateArray . But how do I formulate the query that would fetch the information for all array items? Thanks!

    Read the article

  • Write a recursive function in C that converts a number into a string

    - by user3501779
    I'm studying software engineering, and came across this exercise: it asks to write a recursive function in C language that receives a positive integer and an empty string, and "translates" the number into a string. Meaning that after calling the function, the string we sent would contain the number but as a string of its digits. I wrote this function, but when I tried printing the string, it did print the number I sent, but in reverse. This is the function: void strnum(int n, char *str) { if(n) { strnum(n/10, str+1); *str = n%10 + '0'; } } For example, I sent the number 123 on function call, and the output was 321 instead of 123. I also tried exchanging the two lines within the if statement, and it still does the same. I can't figure out what I did wrong. Can someone help please? NOTE: Use of while and for loop statements is not allowed for the exercise.

    Read the article

  • how to generate a random string, and specify the length you want, or better generate unique string on specification you want

    - by HCP
    There is a library to generate Random numbers, so why in't there a library for generation random strings ? In other words how to generate a random string, and specify the length you want, or better generate unique string on specification you want i.e specify the length, a unique string within my application is enough for me. I know I can create a Guid (globally unique identifier) but those are quite long, longer they need to be. int length = 8; string s = RandomString.NextRandomString(length) uniquestringCollection = new UniquestringsCollection(length) string s2 = uniquestringCollection.GetNext();

    Read the article

  • Iterate over the lines of a string

    - by Space_C0wb0y
    I have a multi-line string defined like this: foo = """ this is a multi-line string. """ I need an iterator that iterates over the individual lines of that string. I could of course do it like this: lineiterator = iter(foo.splitlines()) Is there a more direct way of doing this? In this scenario the string has to traversed once for the splitting, and then again by the parser. It doesn't matter in my test-case, since the string is very short there, I am just asking out of curiosity. Python has so many useful and efficient built-ins for such stuff, but I could find nothing that suits this need.

    Read the article

  • SQL SERVER – CXPACKET – Parallelism – Usual Solution – Wait Type – Day 6 of 28

    - by pinaldave
    CXPACKET has to be most popular one of all wait stats. I have commonly seen this wait stat as one of the top 5 wait stats in most of the systems with more than one CPU. Books On-Line: Occurs when trying to synchronize the query processor exchange iterator. You may consider lowering the degree of parallelism if contention on this wait type becomes a problem. CXPACKET Explanation: When a parallel operation is created for SQL Query, there are multiple threads for a single query. Each query deals with a different set of the data (or rows). Due to some reasons, one or more of the threads lag behind, creating the CXPACKET Wait Stat. There is an organizer/coordinator thread (thread 0), which takes waits for all the threads to complete and gathers result together to present on the client’s side. The organizer thread has to wait for the all the threads to finish before it can move ahead. The Wait by this organizer thread for slow threads to complete is called CXPACKET wait. Note that not all the CXPACKET wait types are bad. You might experience a case when it totally makes sense. There might also be cases when this is unavoidable. If you remove this particular wait type for any query, then that query may run slower because the parallel operations are disabled for the query. Reducing CXPACKET wait: We cannot discuss about reducing the CXPACKET wait without talking about the server workload type. OLTP: On Pure OLTP system, where the transactions are smaller and queries are not long but very quick usually, set the “Maximum Degree of Parallelism” to 1 (one). This way it makes sure that the query never goes for parallelism and does not incur more engine overhead. EXEC sys.sp_configure N'cost threshold for parallelism', N'1' GO RECONFIGURE WITH OVERRIDE GO Data-warehousing / Reporting server: As queries will be running for long time, it is advised to set the “Maximum Degree of Parallelism” to 0 (zero). This way most of the queries will utilize the parallel processor, and long running queries get a boost in their performance due to multiple processors. EXEC sys.sp_configure N'cost threshold for parallelism', N'0' GO RECONFIGURE WITH OVERRIDE GO Mixed System (OLTP & OLAP): Here is the challenge. The right balance has to be found. I have taken a very simple approach. I set the “Maximum Degree of Parallelism” to 2, which means the query still uses parallelism but only on 2 CPUs. However, I keep the “Cost Threshold for Parallelism” very high. This way, not all the queries will qualify for parallelism but only the query with higher cost will go for parallelism. I have found this to work best for a system that has OLTP queries and also where the reporting server is set up. Here, I am setting ‘Cost Threshold for Parallelism’ to 25 values (which is just for illustration); you can choose any value, and you can find it out by experimenting with the system only. In the following script, I am setting the ‘Max Degree of Parallelism’ to 2, which indicates that the query that will have a higher cost (here, more than 25) will qualify for parallel query to run on 2 CPUs. This implies that regardless of the number of CPUs, the query will select any two CPUs to execute itself. EXEC sys.sp_configure N'cost threshold for parallelism', N'25' GO EXEC sys.sp_configure N'max degree of parallelism', N'2' GO RECONFIGURE WITH OVERRIDE GO Read all the post in the Wait Types and Queue series. Additionally a must read comment of Jonathan Kehayias. Note: The information presented here is from my experience and I no way claim it to be accurate. I suggest you all to read the online book for further clarification. All the discussion of Wait Stats over here is generic and it varies from system to system. It is recommended that you test this on the development server before implementing on the production server. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: DMV, Pinal Dave, PostADay, SQL, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQL Wait Stats, SQL Wait Types, T SQL, Technology

    Read the article

  • String.Format Phone Numbers with Extension

    - by ChiliYago
    I am trying to create a an function that formats US phone numbers -- hopefully without looping through each digit. When 10 digits are passed in all is fine. How ever when more than 10 digits are passed in I want the String.Format method to append the extension digits on the right. For example: When 14 digits passed in the result should be:(444)555-2222 x8888 When 12 digits passed in the result should be:(444)555-2222 x88 etc. However what I get with my current attempt is: Passing in 12 digits returns this string '() -949 x555444433' here is what I have so far. public static string _FormatPhone(object phonevalue) { Int64 phoneDigits; if (Int64.TryParse(phonevalue.ToString(), out phoneDigits)) { string cleanPhoneDigits = phoneDigits.ToString(); int digitCount = cleanPhoneDigits.Length; if (digitCount == 10) return String.Format("{0:(###) ###-####}", phoneDigits); else if (digitCount > 10) return String.Format("{0:(###) ###-#### x#########}", phoneDigits); else return cleanPhoneDigits; } return "Format Err#"; } Thanks in advance.

    Read the article

  • What does SQL Server trace flag 253 do?

    - by kamens
    In another question I was trying to research how to control SQL Server's query plan caches: http://stackoverflow.com/questions/2593749/is-there-an-equivalent-of-optionrecompile-or-with-recompile-for-an-entire-c ...and I found trace flag 253 via this article: http://www.sqlservercentral.com/Forums/Topic837613-146-1.aspx The article is correct, if I run DBCC TRACEON(253) and then a number of queries, I can manually check the query plan cache and see that plans have not been inserted. If I run DBCC TRACEOFF(253), query plans are cached as normal. So my question is...what else does this flag do? Does anybody know the official story?

    Read the article

  • Regular expression of unicode characters on string

    - by Marcus King
    I'm working in c# doing some OCR work and have extracted the text I need to work with. Now I need to parse a line using Regular Expressions. string checkNum; string routingNum; string accountNum; Regex regEx = new Regex(@"\u9288\d+\u9288"); Match match = regEx.Match(numbers); if (match.Success) checkNum = match.Value.Remove(0, 1).Remove(match.Value.Length - 1, 1); regEx = new Regex(@"\u9286\d{9}\u9286"); match = regEx.Match(numbers); if(match.Success) routingNum = match.Value.Remove(0, 1).Remove(match.Value.Length - 1, 1); regEx = new Regex(@"\d{10}\u9288"); match = regEx.Match(numbers); if (match.Success) accountNum = match.Value.Remove(match.Value.Length - 1, 1); The problem is that the string contains the necessary unicode characters when I do a .ToCharArray() and inspect the contents of the string, but it never seems to recognize the unicode characters when I parse the string looking for them. I thought strings in C# were unicode by default.

    Read the article

  • Weird problem with string function

    - by wrongusername
    I'm having a weird problem with the following function, which returns a string with all the characters in it after a certain point: string after(int after, string word) { char temp[word.size() - after]; cout << word.size() - after << endl; //output here is as expected for(int a = 0; a < (word.size() - after); a++) { cout << word[a + after]; //and so is this temp[a] = word[a + after]; cout << temp[a]; //and this } cout << endl << temp << endl; //but output here does not always match what I want string returnString = temp; return returnString; } The thing is, when the returned string is 7 chars or less, it works just as expected. When the returned string is 8 chars or more, then it starts spewing nonsense at the end of the expected output. For example, the lines cout << after(1, "12345678") << endl; cout << after(1, "123456789") << endl; gives an output of: 7 22334455667788 2345678 2345678 8 2233445566778899 23456789?,?D~ 23456789?,?D~ What can I do to fix this error, and are there any default C++ functions that can do this for me?

    Read the article

  • Declaring a string array in class header file - compiler thinks string is variable name?

    - by Dave
    Hey everybody, I need a bit of a hand with declaring a string array in my class header file in C++. atm it looks like this: //Maze.h #include <string> class Maze { GLfloat mazeSize, mazeX, mazeY, mazeZ; string* mazeLayout; public: Maze ( ); void render(); }; and the constructor looks like this: //Maze.cpp #include <GL/gl.h> #include "Maze.h" #include <iostream> #include <fstream> Maze::Maze( ) { cin >> mazeSize; mazeLayout = new string[mazeSize]; mazeX = 2/mazeSize; mazeY = 0.25; mazeZ = 2/mazeSize; } I'm getting a compiler error that says: In file included from model-view.cpp:11: Maze.h:14: error: ISO C++ forbids declaration of ‘string’ with no type Maze.h:14: error: expected ‘;’ before ‘*’ token and the only sense that makes to me is that for some reason it thinks I want string as a variable name not as a type declaration. If anybody could help me out that would be fantastic, been looking this up for a while and its giving me the shits lol. Cheers guys

    Read the article

  • MySQL limit from descending order

    - by faya
    Hello, Is it available to write a query to use same "LIMIT (from), (count)", but get result in backwards? In example if I have 8 rows in the table and I want to get 5 rows in two steps I would: first step query: select * from table limit 0, 5 first step result: first 5 rows; second step query: select * from table limit 5, 5 second step result: last 3 rows; But I want to get it vice versa. I mean from the first step I want last 3 rows and from the second I want 5 first rows. Thank you for your answer

    Read the article

  • how to change ASP.NET Configuration tool connection string

    - by Zviadi
    Hello, how can I change ASP.NET Configuration tool-s connection string name? (Which connection string will ASP.NET Configuration tool will use) I'm learning ASP.NET and everywhere and in book that I'm reading now theres connection string named: LocalSqlServer. I want to use my local sql server database instead of sql express to store Roles, Membership and other data. I have used aspnet_regsql.exe to create needed data structures in my database. after that I changed my web.config to look like: <connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Server=(LOCAL); Database=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> but when I run ASP.NET Configuration tool it says that: "The connection name 'ApplicationServices' was not found in the applications configuration or the connection string is empty." ASP.NET Configuration tool uses connection string named: ApplicationServices not LocalSqlServer. cause of that I have to modify web.config to: <connectionStrings> <add name="ApplicationServices" connectionString="Server=(LOCAL); Database=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> and everything works fine. I wish to know why the hell my web site uses connection string named: ApplicationServices and all books and online documentations uses LocalSqlServer? and how to change it to LocalSqlServer? I have: Windows 7 Sql Server 2008 R2 Visual Studio 2010 Premium Project type is website

    Read the article

  • mysql inserts & updates optimized

    - by user271619
    This is an optimization question, mostly. I have many forms on my sites that do simple Inserts and Updates. (Nothing complicated) But, several of the form's input fields are not necessary and may be left empty. (again, nothing complicated) However, my SQL query will have all columns in the Statement. My question, is it best to optimize the Inserts/Update queries appropriately? And only apply the columns that are changed into the query? We all hear that we shouldn't use the "SELECT *" query, unless it's absolutely needed for displaying all columns. But what about Inserts & Updates? Hope this makes sense. I'm sure any amount of optimization is acceptable. But I never really hear about this, specifically, from anyone.

    Read the article

  • c++ creating ambigram from string

    - by mike_hornbeck
    I have a task to implement "void makeAmbigram(char*)" that will print on screen ambigram of latin string or return something like 'ambigram not possible'. Guess it's just about checking if string contains only of SNOXZHI and printing string backwards. Or am I wrong ? I'm a complete noob when dealing with cpp so that's what I've created : #include <iostream> using namespace std; char[]words; char[]reversed; char[] ret_str(char* s) { if(*s != '\0') ret_str(s+1); return s; } void makeAmbigram(char* c) { /* finding chars XIHNOZS and printing ambigram */ } int main() { cin>>words; reversed = ret_str(words); makeAmbigram(reversed); return 0; } I can reverse string but how to check if my reversed string contains only needed chars ? I've found some function but it's hard or even imposible to implement it for greater amount of chars : http://www.java2s.com/Code/C/String/Findcharacterinstringhowtousestrchr.htm

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >