Search Results

Search found 47805 results on 1913 pages for 'return address'.

Page 74/1913 | < Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >

  • How can i return dataset perfectly from sql?

    - by Phsika
    i try to write a winform application: i dislike below codes: DataTable dt = new DataTable(); dt.Load(dr); ds = new DataSet(); ds.Tables.Add(dt); Above part of codes looks unsufficient.How can i best loading dataset? public class LoadDataset { public DataSet GetAllData(string sp) { return LoadSQL(sp); } private DataSet LoadSQL(string sp) { SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString()); SqlCommand cmd = new SqlCommand(sp, con); DataSet ds; try { con.Open(); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); ds = new DataSet(); ds.Tables.Add(dt); return ds; } finally { con.Dispose(); cmd.Dispose(); } } }

    Read the article

  • When does ref($variable) return 'IO'?

    - by Zaid
    Here's the relevant excerpt from the documentation of the ref function: The value returned depends on the type of thing the reference is a reference to. Builtin types include: SCALAR ARRAY HASH CODE REF GLOB LVALUE FORMAT IO VSTRING Regexp Based on this, I imagined that calling ref on a filehandle would return 'IO'. Surprisingly, it doesn't: use strict; use warnings; open my $fileHandle, '<', 'aValidFile'; close $fileHandle; print ref $fileHandle; # prints 'GLOB', not 'IO' perlref tries to explain why: It isn't possible to create a true reference to an IO handle (filehandle or dirhandle) using the backslash operator. The most you can get is a reference to a typeglob, which is actually a complete symbol table entry [...] However, you can still use type globs and globrefs as though they were IO handles. In what circumstances would ref return 'IO' then?

    Read the article

  • Return highest number found in an array of strings

    - by Mdd
    I have an array of objects. The objects have a property called level that is a string which contains a number and is in consistent format. I am trying to find the highest number and return just that one but I seem to be blocked as far as how to proceed from my current code. Here is a fiddle to my current code: http://jsfiddle.net/6sXYR/ Here is my JavaScript: var myArray = [ { color: 'blue', level: 'L1' }, { color: 'red', level: 'L1' }, { color: 'green', level: 'L2' }, { color: 'yellow', level: 'L2' }, { color: 'purple', level: 'L3' } ]; for (var i = 0; i < myArray.length; i++) { console.log( myArray[i].level.substring(1,2) ); }; The result I am trying to get is to return just the number '3' from the example above. The highest number may not always be in the last object in the array, but it will always be in the format of L#.

    Read the article

  • Return latitude/longitude based on entered address

    - by Don
    I'm building a php based application for a client to enter in addresses for their customers' buildings. They'd like the ability to view the location on a map (either as individuals or grouped in a city search). What I'm trying to accomplish is a lookup once the address is entered into a form that populates the database, so after they enter in the addresss, city, state, zip (these are all US locations) they could click a "get lat/long info" link/button that would check to make sure the data is complete, then would lookup the address and return the latitude/longitude into the appropriate form fields. Then the form could be submitted to store the info, and I could later just pull the lat/long when plotting on a map. 1) Does this make sense, or would I be better off just doing the lookup when it's time to plot it? 2) Does anyone have any pointers to solve this problem? I've seen some of the Google/Yahoo API's but it looks like this is more based on the plotting a point part. I may be able to modify it to suit my needs, but I'm just trying to cut some research time posting here with the hopes one of you may have a more direct route. I'll RTFM if I have to... Thanks, D.

    Read the article

  • How to invoke a method with a generic return type using reflection

    - by Andre Luus
    Hi there! I'm trying to invoke a method with reflection that has a generic return type, like this: public class SomeClass<T> { public List<T> GetStuff(); } I get an instance of SomeClass with a call to a Repository's GetClass<T> generic method. MethodInfo lGetSomeClassMethodInfo = typeof(IRepository) .GetMethod("GetClass") .MakeGenericMethod(typeof(SomeClass<>); object lSomeClassInstance = lGetSomeClassMethodInfo.Invoke( lRepositoryInstance, null); After that, I this is where I try to invoke the GetStuff method: typeof(SomeClass<>).GetMethod("GetStuff").Invoke(lSomeClassInstance, null) I get an exception about the fact that the method has generic arguments. However, I can't use MakeGenericMethod to resolve the return type. Also, if instead of typeof(SomeClass<>) I use lSomeClassInstance.GetType() (which should have resolved types) GetMethod("GetStuff") returns null! UPDATE I have found the solution and will post the answer shortly.

    Read the article

  • PHP fsockopen doesnt return anything

    - by Industrial
    Hi! I am modifying a PHP db wrapper for the redis database. Here's how my function looks: public function connect() { $sock = @fsockopen('localhost', '6379', $errno, $errstr, 2); if ($sock === FALSE) { return FALSE; } else { stream_set_timeout($sock, 2); return $sock; } } What I want to do is to call this function from another part in my wrapper: if ($this->connect() !== FALSE) { // Do stuff } How can I get my connect function to send a FALSE when the fsockopen isn't working? Thanks!

    Read the article

  • MySQL - Return number of rows matching query data?

    - by Keir Simmons
    I have a query as follows: SELECT 1 FROM shop_inventory a JOIN shop_items b ON b.id=a.iid AND b.szbid=3362169 AND b.cid=a.cid WHERE a.cid=1 GROUP BY a.bought The only thing I need to do with this data is work out the number of rows returned (which I could do with mysqli -> num_rows;. However, I would like to know if there is a method to return the number of rows that match the query, without having to run num_rows? For example, the query should return one row, with one result, number_of_rows. I hope this makes sense!

    Read the article

  • Return specific HREF attribute using Xpath query

    - by Michael Pasqualone
    Having a major brain freeze, I have the following chunk of code: // Get web address $domQuery = query_HtmlDocument($html, '//a[@class="productLink"]'); foreach($domQuery as $rtn) { $web = $rtn->getAttribute('href'); } Which obviously gets the entire href attribute, however I only want 1 specific attribute within the href. I.e. If the href is: /website/product1234.do?code=1234&version=1.3&somethingelse=blaah I only want to return the variable for "version", so wish to only return "1.3" in my example. What's most efficient way to do this?

    Read the article

  • Is it necessarily bad style to ignore the return value of a method

    - by Jono
    Let's say I have a C# method public void CheckXYZ(int xyz) { // do some operation with side effects } Elsewhere in the same class is another method public int GetCheckedXYZ(int xyz) { int abc; // functionally equivalent operation to CheckXYZ, // with additional side effect of assigning a value to abc return abc; // this value is calculated during the check above } Is it necessarily bad style to refactor this by removing the CheckXYZ method, and replacing all existing CheckXYZ() calls with GetCheckedXYZ(), ignoring the return value? The returned type isn't IDisposable in this case. Does it come down to discretion?

    Read the article

  • jQuery ajax request to php, how to return plain text only

    - by jyoseph
    I am making an ajax request to a php page and I cannot for the life of me get it to just return plain text. $.ajax({ type: 'GET', url: '/shipping/test.php', cache: false, dataType: 'text', data: myData, success: function(data){ console.log(data) } }); in test.php I am including this script to get UPS rates. I am then calling the function with $rate = ups($dest_zip,$service,$weight,$length,$width,$height); I am doing echo $rate; at the bottom of test.php. When viewed in a browser shows the rate, that's great. But when I request the page via ajax I get a bunch of XML. Pastie here: http://pastie.org/1416142 My question is, how do I get it so I can just return the plain text string from the ajax call, where the result data will be a number? Edit, here's what I see in Firebug- Response tab: HTML tab:

    Read the article

  • Best way to return result from business layer to presentation layer when using LINQ-to-SQL

    - by samsur
    I have a business layer that has DTOs that are used in the presentation layer. This application uses entity framework. Here is an example of a class called RoleDTO: public class RoleDTO { public Guid RoleId { get; set; } public string RoleName { get; set; } public string RoleDescription { get; set; } public int? OrganizationId { get; set; } } In the BLL I want to have a method that returns a list of DTO. I would like to know which is the better approach: returning IQueryable or list of DTOs. Although I feel that returning IQueryable is not a good idea because the connection needs to be open. Here are the 2 different methods using the different approaches: First approach public class RoleBLL { private servicedeskEntities sde; public RoleBLL() { sde = new servicedeskEntities(); } public IQueryable<RoleDTO> GetAllRoles() { IQueryable<RoleDTO> role = from r in sde.Roles select new RoleDTO() { RoleId = r.RoleID, RoleName = r.RoleName, RoleDescription = r.RoleDescription, OrganizationId = r.OrganizationId }; return role; } Note: in the above method the DataContext is a private attribute and set in the constructor, so that the connection stays opened. Second approach public static List<RoleDTO> GetAllRoles() { List<RoleDTO> roleDTO = new List<RoleDTO>(); using (servicedeskEntities sde = new servicedeskEntities()) { var roles = from pri in sde.Roles select new { pri.RoleID, pri.RoleName, pri.RoleDescription }; //Add the role entites to the DTO list and return. This is necessary as anonymous types can be returned acrosss methods foreach (var item in roles) { RoleDTO roleItem = new RoleDTO(); roleItem.RoleId = item.RoleID; roleItem.RoleDescription = item.RoleDescription; roleItem.RoleName = item.RoleName; roleDTO.Add(roleItem); } return roleDTO; } } Please let me know, if there is a better approach.

    Read the article

  • Most efficient way of checking for a return from a function call in Perl

    - by Gaurav Dadhania
    I want to add the return value from the function call to an array iff something is returned (not by default, i.e. if I have a return statement in the subroutine.) so I'm using unshift @{$errors}, "HashValidator::$vfunction($hashref)"; but this actually adds the string of the function call to the array. I also tried unshift @{$errors}, $temp if defined my $temp = "HashValidator::$vfunction($hashref)"; with the same result. What would a perl one-liner look like that does this efficiently (I know I can do the ugly, multi-line check but I want to learn). Thanks,

    Read the article

  • Html POST and return the same form with the values

    - by vtortola
    Hi, I'm learning web development, and I don't know how do this simple thing. I've a html form with "text", "radio" and "checkbox" controls, that POST the values to the server and it saves them, for example in a file. I save the POST in raw format: key=value&key=value&key=value&key=value and I'd like that when the user open the form back, return the form with the saved values already in the controls. Is there any neat way to do this? Or should I parse the POST string and set the values one by one in the controls at the server level? I think, I could return the saved data in a hidden input control, and after with a javascript I could do a getElementById(key) and set the value to each input control... but do I need to put the post string in a special format? How would you do it? Thank you in advance.

    Read the article

  • Android return to the original position of the view after MotionEvent

    - by Kurty
    My application currently changes to another random int (View) when I let go of it (ACTION_UP) but the view stays in the same spot where I dropped it. I want it to return to the original location (the middle of the screen) when I drop it so I can repeat the process. // OnTouch and MotionEvent OnTouchListener dragt = new OnTouchListener() { public boolean onTouch(View v, MotionEvent me) { FrameLayout.LayoutParams par = (FrameLayout.LayoutParams) v.getLayoutParams(); switch (v.getId()) { case R.id.randomView: } switch(me.getAction()) { case MotionEvent.ACTION_MOVE: par.gravity = 0; par.setMargins((int)me.getRawX() - (v.getWidth())/2, (int)me.getRawY() - (v.getHeight())/2, 0, 0); v.setLayoutParams(par); break; case MotionEvent.ACTION_UP: // tallies score. score++; textScore.setText(String.valueOf(score)); // this generates the new view but the location is still the same color.setImageResource(mImageIds[rgenerator.nextInt(mImageIds.length)]); break; } return true; } };

    Read the article

  • Fault address when malloc/free pthread_t across threads

    - by scleung
    Fault address occurred when i malloc pthread_t to save a newly created thread id and free it in another thread. Codes as follows: typedef struct _TaskInfo { // int dummy_int; pthread_t tid; } TaskInfo; void* dummy_task(void* pArg) { free(pArg); return NULL; } void create_task() { TaskInfo *pInfo; pthread_attr_t attr; // set detached state stuff ... pInfo = (TaskInfo*) malloc(sizeof(TaskInfo)); pthread_create(&pInfo->tid, &attr, dummy_task, pInfo); // destroy pthread attribute stuff ... } int main() { int i; while(i < 10000) { create_task(); ++i; } return 0; } When I uncomment the member dummy_int of TaskInfo it sometimes ran successfully, but sometimes failed. My platform is VMWare + Ubuntu 9.10 + ndk r3 Thanks!

    Read the article

  • Django admin return to page after save

    - by Thordin9
    Hi all, I have 3 pages of items listed in my django application admin. After i edit one of them (lets say it is in page 2) and save my changes, i return to page 1 of my listing. How can i make it so i return to the page the item is in? I looked into some similar questions here at stackoverflow and i believe that i need to use javascript to send a httpresponse with the location header. But how i can determine the page the item is in? any help is appreciated

    Read the article

  • Derived template override return type of member function C++

    - by Ruud v A
    I am writing matrix classes. Take a look at this definition: template <typename T, unsigned int dimension_x, unsigned int dimension_y> class generic_matrix { ... generic_matrix<T, dimension_x - 1, dimension_y - 1> minor(unsigned int x, unsigned int y) const { ... } ... } template <typename T, unsigned int dimension> class generic_square_matrix : public generic_matrix<T, dimension, dimension> { ... generic_square_matrix(const generic_matrix<T, dimension, dimension>& other) { ... } ... void foo(); } The generic_square_matrix class provides additional functions like matrix multiplication. Doing this is no problem: generic_square_matrix<T, 4> m = generic_matrix<T, 4, 4>(); It is possible to assign any square matrix to M, even though the type is not generic_square_matrix, due to the constructor. This is possible because the data does not change across children, only the supported functions. This is also possible: generic_square_matrix<T, 4> m = generic_square_matrix<T, 5>().minor(1,1); Same conversion applies here. But now comes the problem: generic_square_matrix<T, 4>().minor(1,1).foo(); //problem, foo is not in generic_matrix<T, 3, 3> To solve this I would like generic_square_matrix::minor to return a generic_square_matrix instead of a generic_matrix. The only possible way to do this, I think is to use template specialisation. But since a specialisation is basically treated like a separate class, I have to redefine all functions. I cannot call the function of the non-specialised class as you would do with a derived class, so I have to copy the entire function. This is not a very nice generic-programming solution, and a lot of work. C++ almost has a solution for my problem: a virtual function of a derived class, can return a pointer or reference to a different class than the base class returns, if this class is derived from the class that the base class returns. generic_square_matrix is derived from generic_matrix, but the function does not return a pointer nor reference, so this doesn't apply here. Is there a solution to this problem (possibly involving an entirely other structure; my only requirements are that the dimensions are a template parameter and that square matrices can have additional functionality). Thanks in advance, Ruud

    Read the article

  • C# ...extract email address from inside 100's of text files

    - by Developer
    My SMTP server got 100's of errors when sending lots of emails. Now have lots of .BAD files each one containing an error message and somewhere in the middle, the actual email address it was supposed to be sent to. What is the easiest way to extract from each file "just" the "email address", so that I can have a list of the actual failed emails? I can code in C# and any suggestion will be truly welcomed. BAD SAMPLE TEXT: From: [email protected] To: [email protected] Date: Tue, 25 Sep 2012 12:12:09 -0700 MIME-Version: 1.0 Content-Type: multipart/report; report-type=delivery-status; boundary="9B095B5ADSN=_01CD9B35032DF58000000066my.server.co" X-DSNContext: 7ce717b1 - 1386 - 00000002 - C00402D1 Message-ID: Subject: Delivery Status Notification (Failure) This is a MIME-formatted message. Portions of this message may be unreadable without a MIME-capable mail program. --9B095B5ADSN=_01CD9B35032DF58000000066my.server.co Content-Type: text/plain; charset=unicode-1-1-utf-7 This is an automatically generated Delivery Status Notification. Unable to deliver message to the following recipients, due to being unable to connect successfully to the destination mail server. [email protected] --9B095B5ADSN=_01CD9B35032DF58000000066my.server.com Content-Type: message/delivery-status Reporting-MTA: dns;my.server.com Received-From-MTA: dns;Social Arrival-Date: Tue, 25 Sep 2012 11:45:15 -0700 Final-Recipient: rfc822;[email protected] Action: failed Status: 4.4.7 --9B095B5ADSN=_01CD9B35032DF58000000066my.server.com Content-Type: message/rfc822 Received: from Social ([127.0.0.1]) by my.server.com with Microsoft SMTPSVC(7.5.7601.17514); Tue, 25 Sep 2012 11:45:15 -0700 ====================================== ...and lots more text after ===================== Mainly I want to find the "[email protected]" email right in the middle...

    Read the article

  • How to return Json from WCF Service?

    - by Zinoo
    Hi, I have the piece of code below of a template Ajax enabled WCF service. What can i do to make it return JSon instead of XML? thanks. using System; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Activation; [ServiceContract(Namespace = "WCFServiceEight")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class CostService { // Add [WebGet] attribute to use HTTP GET [OperationContract] [WebGet] public double CostOfSandwiches(int quantity) { return 1.25 * quantity; } }

    Read the article

< Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >