Sunday, 15 March 2015

c# - How to use descending with ascending in linq? -



c# - How to use descending with ascending in linq? -

i have query

select * fellow member order d_no.member desc, datebirth asc

i thinking how can in linq? have list<member>

i used this

var result = member.orderbydescending(s => s.d_no).orderby(y => y.datebirth ).tolist();

is not working, idea?

orderbydescending returns instance of type iorderedenumerable<tsource>. can phone call thenby or thenbydescending apply sec (or third) ordering constraint.

var result = member.orderbydescending(s => s.d_no) .thenby(y => y.datebirth ) .tolist();

c# linq

Java Simple EchoServer won't work -



Java Simple EchoServer won't work -

i read through lot , found many examples doing trying do. can't find issue in code @ all. may need fresh set of eyes @ code. risk of beingness flagged duplicate thread here goes. have simple java code. opens port. connects socket that. gets inputstream , outputstream. puts text output stream , inputstream tries read text. when mehtod readline executed not homecoming code. keeps running , never comes main method.

import java.net.*; import java.io.*; import java.io.objectinputstream.getfield; public class echoserver { public static void main(string[] args) { // todo auto-generated method stub string hostname = "127.0.0.1"; // inetaddress.getlocalhost() int portnumber = 5000; serversocket ss = null; socket echosocket = null; seek { ss = new serversocket(portnumber); echosocket = new socket(hostname, portnumber); // echosocket = ss.accept(); system.out.println("open"); system.out.println(echosocket.isbound()); printwriter author = new printwriter(echosocket.getoutputstream()); (int = 0; < 100; i++) { writer.print("test string"); } writer.flush(); // writer.close(); system.out.println("inputstream read"); datainputstream = new datainputstream(echosocket.getinputstream()); string fromstream = is.readline(); system.out.println(fromstream); system.out.println("bufferreader read"); bufferedreader reader = new bufferedreader(new inputstreamreader(echosocket.getinputstream())); string fromreader = reader.readline(); system.out.println(fromreader); } grab (unknownhostexception ex1) { // todo auto-generated grab block system.out.println("ex1"); ex1.printstacktrace(); } grab (ioexception ex2) { // todo: handle exception system.out.println("ex2"); ex2.printstacktrace(); } { seek { echosocket.close(); ss.close(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } } } }

edit : updated code below... issue in code while loop in server.run never ends. looked other attributes (i remember istextavailable) not find it. thought behind code convert chat client. needless struggle !

edit 2: found the issue. never closed socket author end listner kept on listening ! help !

clientsocket.close();

added 1 line , worked!

import java.net.*; import java.io.*; import java.io.objectinputstream.getfield; import java.util.*; public class echoserver { static echoserver echo; public static class client implements runnable { socket clientsocket; string hostname = "127.0.0.1"; int portnumber = 5000; static int onesleep = 0; public void run(){ system.out.println("client run " + new date()); seek { clientsocket = new socket(hostname,portnumber); printwriter author = new printwriter(clientsocket.getoutputstream()); (int = 0; < 10; i++) { writer.println("test string " + ); } writer.flush(); clientsocket.close(); } grab (unknownhostexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } } } public class server implements runnable { public void run(){ system.out.println("server run" + new date()); int portnumber = 5000; serversocket ss = null; socket serversocket = null; inputstreamreader streamreader; seek { ss = new serversocket(portnumber); serversocket = ss.accept(); system.out.println("bufferreader read " + new date()); streamreader = new inputstreamreader(serversocket.getinputstream()); bufferedreader reader = new bufferedreader(streamreader); string fromreader; system.out.println(reader.ready()); system.out.println(reader.readline()); while ((fromreader = reader.readline()) != null) { system.out.println(fromreader); } system.out.println("after while in server run"); } grab (ioexception ex_server) { // todo auto-generated grab block system.out.println("server run error " + new date()); ex_server.printstacktrace(); } { seek { serversocket.close(); ss.close(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } } system.out.println("open" + new date()); system.out.println(serversocket.isbound()); } } public void go(){ server server = new server(); thread serverthread = new thread(server); serverthread.start(); client client = new client(); thread clientthread = new thread(client); clientthread.start(); } public static void main(string[] args) { // todo auto-generated method stub echo = new echoserver(); echo.go(); } }

i had prepared version of post earlier, based on lastly comment in other answer, seems have figured out. i'll posting anyways, in case of help.

the broad reply class, have it, represents both client-side , server-side portions within same thread / process. you've seen, you're able write info outbound (or client-side) socket, server-side component never gets chance hear incoming connections.

consequently, when effort read info inbound (or server-side) socket's input stream, nil exists because nil received. readline() method blocks until info available, why programme seems hold @ point. additionally, haifzhan said, creating new socket using new socket(...) doesn't found connection, have socket nil in stream.

the serversocket#accept method need utilize in order hear connections. method create socket you, can effort read stream. haifzhan said, method blocks until connection established, why cannot function in single-threaded environment.

to within same application, you'll need separate components , run them in separate threads. seek following:

public class echoclient { public static void main(string[] args) throws interruptedexception { new thread(new echoserver()).start(); // start server thread string hostname = "localhost"; int portnumber = 5000; seek { socket outboundsocket = new socket(hostname, portnumber); system.out.println("echo client send info server..."); printwriter author = new printwriter(outboundsocket.getoutputstream()); (int = 0; < 100; i++) { writer.print("test string"); } system.out.println("data has been sent"); writer.flush(); outboundsocket.close(); } grab (unknownhostexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } } }

and server component, operates separate thread:

public class echoserver implements runnable { public void run(){ seek { serversocket ss = new serversocket(5000); system.out.println("waiting connection..."); socket inboundsocket = ss.accept(); system.out.println("inputstream read"); datainputstream = new datainputstream(inboundsocket.getinputstream()); bufferedreader reader = new bufferedreader(new inputstreamreader(is)); string fromstream = reader.readline(); system.out.println(fromstream); system.out.println("bufferreader read"); ss.close(); } grab (ioexception e) { e.printstacktrace(); } } }

java

OpenFileDialog.FileName to upload an image using vb.net to SQL Server 2008 -



OpenFileDialog.FileName to upload an image using vb.net to SQL Server 2008 -

i have code uploading photo in vb.net sql server. on openfiledialog need imagename, it's location in text field.

dim bmap image dim info idataobject dim fd openfiledialog = new openfiledialog() fd.title = "select image." fd.initialdirectory = my.settings.imagedefect fd.filter = "all files|*.*|bitmaps|*.bmp|gifs|*.gif|jpegs|*.jpg|pngs|*.png" fd.restoredirectory = false if fd.showdialog() = dialogresult.ok picturebox.imagelocation = fd.filename **txtimagefile.text = fd.filename**

in text field, have c:\users\susi\pictures\capture.png

how can capture.png in text field? please help me, give thanks you.

use static methods of path class (path.getfilename)

txtimagefile.text = = path.getfilename(fd.filename)

vb.net sql-server-2008 image-uploading

Android string values formatting -



Android string values formatting -

my name <b>%1$s</b> <string name="funky_format">my name &lt;b&gt;%1$s&lt;/b&gt;</string>

what lastly formatting mean?

the reason string looks funky it's doing both formatting , html. here's description of documentation, states:

sometimes may want create styled text resource used format string. normally, won't work because string.format(string, object...) method strip style info string. work-around write html tags escaped entities.

android

jquery - SyntaxError: missing ; before statement Getting this error when trying to call google place search api -



jquery - SyntaxError: missing ; before statement Getting this error when trying to call google place search api -

getting 'syntaxerror: missing ; before statement' error when trying run ajax code fetch atm within 1 km range.

var url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"; jquery.ajax({ url: url, datatype: 'jsonp', data: { 'location': '-33.8670522,151.1957362', 'radius': 1000, 'types': 'atm', 'name': '', 'sensor': false, 'key': api_key }, success: function(response) { alert('success'); } });

i have searched many articles didnt found solution. if remove 'p' 'jsonp' there no response cause cross domain. how can solve issue?

there no syntax-error in code, error comes via response.

the places-webservice doesn't back upwards jsonp, can't request service via $.ajax

use methods of places-library of maps-javascript-api: https://developers.google.com/maps/documentation/javascript/places#place_search_requests

jquery json google-maps-api-3 google-places-api

Clojure.contrib.sql: How do I retrieve the results of a select statement into a vector that can be accessed anytime? -



Clojure.contrib.sql: How do I retrieve the results of a select statement into a vector that can be accessed anytime? -

for example, in query:

(clojure.contrib.sql/with-query-results rows ["select count(*) tablename"] (doseq [record rows] (println (vals record))))

it seems record , rows don't exist outside scope want exist anytime me access.

update: tried next lines of code

(def asdf []) (sql/with-connection db (sql/with-query-results rows ["select * tablename"] (doseq [record rows] (def asdf (conj asdf record))))) (println asdf)

why print statement of asdf above homecoming empty when added rows in sql statement?

you seem lack basic understanding of clojure's underlying principles, in particular immutable info structures. conj phone call doesn't modify var asdf -- var not variable. next (untested)

(def asdf (sql/with-connection db (doall (sql/with-query-results rows ["select * tablename"]))))

to store result straight value of asdf, not want. familiar clojure's take on functional programming instead.

sql clojure

heroku - Rails not connecting to Redis (RedisToGo) -



heroku - Rails not connecting to Redis (RedisToGo) -

i've been trying deploy rails 4 app heroku, still getting same error:

error connecting redis on 127.0.0.1:6379 (econnrefused) (redis::cannotconnecterror)

i'm using redistogo , did configuration steps showed here. environment variable correctly set up.

when trying connect redis (as shown in documentation) locally works fine.

i resolve adding redis_url environment variable instead of redistogo_url or redis_provider. sidekiq official documentation advices utilize provider_url, though couldn't create work.

ruby-on-rails heroku redistogo