Daily Archives

Articles indexed Wednesday April 28 2010

Page 16/119 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • C# NullReferenceException when passing DataTable

    - by Timothy
    I've been struggling with a NullReferenceException and hope someone here will be able to point me in the right direction. I'm trying to create and populate a DataTable and then show the results in a DataGridView control. The basic code follows, and Execution stops with a NullReferenceException at the point where I invoke the new UpdateResults_Delegate. Oddly enough, I can trace entries.Rows.Count successfully before I return it from QueryEventEntries, so I can at least show 1) entries is not a null reference, and 2) the DataTable contains rows of data. I know I have to be doing something wrong, but I just don't know what. private delegate void UpdateResults_Delegate(DataTable entries); private void UpdateResults(DataTable entries) { dataGridView.DataSource = entries; } private void button_Click(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart(PerformQuery)); t.Start(); } private void PerformQuery() { DateTime start = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, 0, 0, 0); DateTime stop = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, 0, 0, 0); DataTable entries = QueryEventEntries(start, stop); Invoke(new UpdateResults_Delegate(UpdateResults), entries); } private DataTable QueryEventEntries(DateTime start, DateTime stop) { DataTable entries = new DataTable(); entries.Columns.Add("colEventType", typeof(Int32)); entries.Columns.Add("colTimestamp", typeof(Int32)); entries.Columns.Add("colDetails", typeof(String)); ... conn.Open(); using (SqlDataReader r = cmd.ExecuteReader()) { while (r.Read()) { entries.Rows.Add(result.GetInt32(0), result.GetInt32(1), result.GetString(2)); } } return entries; }

    Read the article

  • Core Data 1-to-many relationship: List all related objects as section header in UITableView

    - by Snej
    Hi: I struggle with Core Data on the iPhone about the following: I have a 1-to-many relationship in Core Data. Assume the entities are called recipe and category. A category can have many recipes. I accomplished to get all recipes listed in a UITableView with section headers named after the category. What i want to achieve is to list all categories as section header, even those which have no recipe: category1 <--- this one should be displayed too category2 recipe_x recipe_y category3 recipe_z NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Recipe" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; [fetchRequest setFetchBatchSize:10]; NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"category.categoryName" ascending:YES]; NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"recipeName" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor1,sortDescriptor2, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"category.categoryName" cacheName:@"Recipes"]; What is the most elegant way to achieve this with core data?

    Read the article

  • django simple approach to multi-field search

    - by Scott Willman
    I have a simple address book app that I want to make searchable. The model would look something like: class Address(models.Model): address1 = models.CharField("Address Line 1", max_length=128) address2 = models.CharField("Address Line 2", max_length=128) city = models.CharField("City", max_length=128) state = models.CharField("State", max_length=24) zipCode = models.CharField("Zip Code", max_length=24) def __unicode__(self): return "%s %s, %s, %s, %s" % (self.address1, self.address2, self.city, self.state, self.zipCode) class Entry(models.Model): name = models.CharField("Official School Name", max_length=128) createdBy = models.ForeignKey(User) address = models.ForeignKey(Address, unique=True) def __unicode__(self): return "%s - %s, %s" % (self.name, self.address.city, self.address.state) I want the searching to be fairly loose, like: Bank of America Los Angeles 91345. It seems like I want a field that contains all of those elements into one that I can search, but that also seems redundant. I was hoping I could add a method to the Entry model like this: def _getSearchText(self): return "%s %s %s" % (self.name, self.address, self.mascot) searchText = property(_getSearchText) ...and search that as a field, but I suppose that's wishful thinking... How should I approach this using basic Django and SqLite (this is a learning exercise). Thank you!!

    Read the article

  • how to get jquery.couch.app.js to work with IE8

    - by fuzzy lollipop
    I have tested this on Windows XP SP3 and Windows 7 Ultimate in IE7 and IE8 (in all compatiblity modes) and it fails the same way on both. I am running the latest HEAD from the the couchapp repository. This works fine on my OSX 10.6.3 development machine. I have tested with Chrome 4.1.249.1064 (45376) and Firefox 3.6 and they both work fine. As do the Safari 4 and Firefox 3.6 on OSX 10.6.3 Here is the error message Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Wed, 28 Apr 2010 03:32:55 UTC Message: Object doesn't support this property or method Line: 159 Char: 7 Code: 0 URI: http://192.168.0.105:5984/test/_design/test/vendor/couchapp/jquery.couch.app.js and here is the "offending" bit of code, which works on Chrome, Firefox and Safari just fine. If says the failure is on the like that qs.forEach() from the file jquery.couch.app.js 157 var qs = document.location.search.replace(/^\?/,'').split('&'); 158 var q = {}; 159 qs.forEach(function(param) { 160 var ps = param.split('='); 161 var k = decodeURIComponent(ps[0]); 162 var v = decodeURIComponent(ps[1]); 163 if (["startkey", "endkey", "key"].indexOf(k) != -1) { 164 q[k] = JSON.parse(v); 165 } else { 166 q[k] = v; 167 } 168 });

    Read the article

  • How to produce precisely-timed tone and silence?

    - by Bob Denny
    I have a C# project that plays Morse code for RSS feeds. I write it using Managed DirectX, only to discover that Managed DirectX is old and deprecated. The task I have is to play pure sine wave bursts interspersed with silence periods (the code) which are precisely timed as to their duration. I need to be able to call a function which plays a pure tone for so many milliseconds, then Thread.Sleep() then play another, etc. At its fastest, the tones and spaces can be as short as 40ms. It's working quite well in Managed DirectX. To get the precisely timed tone I create 1 sec. of sine wave into a secondary buffer, then to play a tone of a certain duration I seek forward to within x milliseconds of the end of the buffer then play. I've tried System.Media.SoundPlayer. It's a loser because you have to Play(), Sleep(), then Stop() for arbitrary tone lengths. The result is a tone that is too long, variable by CPU load. It takes an indeterminate amount of time to actually stop the tone. I then embarked on a lengthy attempt to use NAudio 1.3. I ended up with a memory resident stream providing the tone data, and again seeking forward leaving the desired length of tone remaining in the stream, then playing. This worked OK on the DirectSoundOut class for a while (see below) but the WaveOut class quickly dies with an internal assert saying that buffers are still on the queue despite PlayerStopped = true. This is odd since I play to the end then put a wait of the same duration between the end of the tone and the start of the next. You'd think that 80ms after starting Play of a 40 ms tone that it wouldn't have buffers on the queue. DirectSoundOut works well for a while, but its problem is that for every tone burst Play() it spins off a separate thread. Eventually (5 min or so) it just stops working. You can see thread after thread after thread exiting in the Output window while running the project in VS2008 IDE. I don't create new objects during playing, I just Seek() the tone stream then call Play() over and over, so I don't think it's a problem with orphaned buffers/whatever piling up till it's choked. I'm out of patience on this one, so I'm asking in the hopes that someone here has faced a similar requirement and can steer me in a direction with a likely solution.

    Read the article

  • How to add a slot to my main window in Qt builder?

    - by George Edison
    I am using Qt Builder to create a simple window. I used the menu editor to add a menu. Now, I figured out how to connect one of the menu items to the close() method of the main window. My problem is how to add a slot to the main window. Here is what I have: private slots: void OnAbout(); However, I can't get this method to show up in the 'Signals and Slots Editor'. How can I get it to show up?

    Read the article

  • What's the difference between $get and $find in JavaScript?

    - by RoboShop
    Hi, I'm a .NET programmer who've just started to learn more about client side scripting, and I was wondering sometimes you use $get('value') and $find('value') and I've discovered that these are just shortcuts for document.getElementById('value') and Sys.Application.findComponent('value'), respectively. However, I still don't understand: what is the difference between these two functions in JavaScript? What exactly are they looking up/retrieving when invoked? Thanks in advance.

    Read the article

  • Does ASP.NET Make Request Scheduling Decisions Based Upon SessionID?

    - by Mike Murphy
    I know that a properly implemented SessionStateStoreProvider maintains an exclusive lock on session data for the duration of a request. However, considering that multiple requests could arrive simultaneously (e.g. via IFRAMEs) all but one would be able to make forward progress. All the other requests would block for a bit and reduce the number of worker threads available during that time. It seems if ASP.NET "peeked" at the session IDs on the requests early on, it could avoid running requests simultaneously that were on the same session. This would improve throughput under load for pages that didn't want to give up using IFRAMEs. This seems plausible enough that it might be true.

    Read the article

  • WPF: Can't get to original source from ExecutedRoutedEventArgs

    - by Ikhail
    I have a problem getting to the original source of a command using ExecutedRoutedEventArgs. I'm creating a simple splitbutton, in which a menu will appear below a dedicated button, as another button is pressed. When I click a menuitem in the appearing menu a command is fired. This command is registered on the splitbutton. And the idea is to get to the menuitem beeing clicked, by using the ExecutedRoutedEventsArgs. Ok, now the problem. If I choose to have the popup menu shown by default (IsOpen="True") and I click one of the menuitems I can get to the originalsource (thus the menuitem) from the ExecutedRoutedEventArgs - no problem. However, if I first click the button to show the menu and THEN click on a menuitem, the originalsource of the command will be the button instead of the MenuItem! Here's the controltemplate for the splitbutton: <ControlTemplate TargetType="{x:Type usc:SplitButton}"> <StackPanel Orientation="Horizontal"> <Button Name="mybutton"> <StackPanel> <Popup usc:SplitButton.IsPopup="True" IsOpen="True" Name="myPopup" PlacementTarget="{Binding ElementName=mybutton}" StaysOpen="False" Placement="Bottom"> <Border BorderBrush="Beige" BorderThickness="1"> <Menu Width="120"> <MenuItem Header="item1" Command="usc:SplitButton.MenuItemClickCommand" /> <MenuItem Header="item2" /> <MenuItem Header="item3" /> </Menu> </Border> </Popup> <TextBlock Text="MySplitbutton" /> </StackPanel> </Button> <Button Content="OK" Command="usc:SplitButton.ShowMenuCommand" /> </StackPanel> </ControlTemplate> The OK button fires a ShowMenuCommand on the SplitButton, which sets the IsOpen property on the Popup to True. Any ideas why the OK button (after having activated the menu) is the OriginalSource when a menuitem is clicked? Thanks.

    Read the article

  • Induction of graduate programmers

    - by spong
    What are some practical ideas that you have found useful for bringing graduates on to your team in their first job? Some of the things that are working well for us include: Assigning a mentor to assist the learning process Written coding standards/guidelines Spending a period of time with the test team to learn the product Where possible, a broad range of experiences in the first few months Anything else that works well for you? A related question can be found here.

    Read the article

  • Display custom title bar for Android with XML

    - by Casebash
    In Android documentation describing "Configuring General Window Properties", it is suggested that specifying properties via XML is preferable whenever possible to avoid seeing the title bar flash. As an example, instead of setting Window.FEATURE_NO_TITLE with requestWindowFeature, they set it to @android:style/Theme.NoTitleBar. Is there a similar way to set a custom title bar to be used in the XML? Update: I just found this article, according to which this article, the best way to draw a title bar is to ignore FEATURE_CUSTOM_TITLE and instead just draw the title bar as part of your main view. This would not only avoid the flashing, but also problems caused by padding.

    Read the article

  • Cannot debug in visual studio 2008

    - by Chin
    I recently reopened a project and on trying to debug the breakpoint only shows as a red circle and gives the following message "The breakpoint will not currently be hit. No symbols have been loaded for this document" I notice there are no PB files in the bin directory. I presume I need to rebuild the debug files. Does anybody know how to go about this? Any help much appreciated.

    Read the article

  • iPhone UIScrollview with UIButtons - how to recreate springboard?

    - by Patrick
    I'm trying to create a springboard-like interface within my app. I'm trying to use UIButtons added to a UIScrollView. The problem I'm running in to is with the buttons not passing any touches to the UIScrollView - if I try to flick/slide and happen to press on the button it doesn't register for the UIScrollView, but if I flick the space between buttons it will work. The buttons do click/work if I touch them. Is there a property or setting that forces the button to send the touch events up to its parent (superview)? Do the buttons need to be added to something else before being added the UIScrollView? Here is my code: //init scrolling area UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 480, 480)]; scrollView.contentSize = CGSizeMake(480, 1000); scrollView.bounces = NO; scrollView.delaysContentTouches = NO; //create background image UIImageView *rowsBackground = [[UIImageView alloc] initWithImage:[self scaleAndRotateImage:[UIImage imageNamed:@"mylongbackground.png"]]]; rowsBackground.userInteractionEnabled = YES; //create button UIButton *btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; btn.frame = CGRectMake(100, 850, 150, 150); btn.bounds = CGRectMake(0, 0, 150.0, 150.0); [btn setImage:[self scaleAndRotateImage:[UIImage imageNamed:@"basicbutton.png"]] forState:UIControlStateNormal]; [btn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; //add "stuff" to scrolling area [scrollView addSubview:rowsBackground]; [scrollView addSubview:btn]; //add scrolling area to cocos2d //this is just a UIWindow [[[Director sharedDirector] openGLView] addSubview:scrollView]; //mem-mgmt [rowsBackground release]; [btn release]; [scrollView release];

    Read the article

  • How is <tgmath.h> implemented?

    - by sync
    C doesn't have (to the best of my knowledge) overloading or templates, right? So how can a set of type-agnostic functions with the same name exist in plain ol' C? The usual compile-time trickery would involve a whole bunch of macros, wouldn't it?

    Read the article

  • WP_Insert_Post and GUID Issue [Wordpress]

    - by morningglory
    Hello, I have a posting form at my theme. I used wp_insert_post there. My code looks like this $post = array( 'ID' => '', 'post_author' => $post_author, 'post_category' => $post_category, 'post_content' => $post_content, 'post_title' => $post_title, 'post_status' => 'publish', ); $post_id = wp_insert_post($post); $fullpost = get_post($post_id); wp_redirect($fullpost->guid); Everything works fine. But when it's inserted to the database, at the GUID field, the entry format is like this permalinks_structure/id. So if my permalinks_structure is like /category/id , it become like http://www.example.com/uncategorized/1. So the problem is, if i post through wordpress admin panel, GUID of the post is http://www.example.com?p=1 . So my post database GUID become mess, because if i want to change permalinks_structure , the post which becomes from outside form will follow the structure. What I want to do is, I want to get the GUID like that I posted through admin panel which is http://www.example.com?p=1 How can i do it ? Please point me out. Thank you.

    Read the article

  • Design pattern: Polymorphism for list of objects

    - by ziang
    Suppose I have a class A, and A1, A2 inherits from A. There are 2 functions: List<A1> getListA1(){...} List<A2> getListA2(){...} Now I want to do something similar to both A1 and A2 in another function public void process(List<A>){...} If I want to pass the instance of either ListA1 or ListA2, of course the types doesn't match because the compiler doesn't allow the coercion from List< A1 to List< A. I can't do something like this: List<A1> listA1 = getListA1(); List<A> newList = (List<A>)listA1; //this is not allowed. So what is the best approach to the process()? Is there any way to do it in a universal way rather than write the similar code to both List and List?

    Read the article

  • iPhone: NSOperationQueue running operations serially

    - by Greg Maletic
    I have a singleton NSOperationQueue that handles all of my network requests. I'm noticing, however, that when I have one particularly long operation running (this particular operation takes at least 25 seconds), my other operations don't run until it completes. maxConcurrentOperationCount is set to NSOperationQueueDefaultMaxConcurrentOperationCount, so I don't believe that's the issue. Any reason why this would be happening? Besides spawning multiple NSOperationQueues (a solution that I'm not sure would work, nor am I sure it's a good idea), what's the best way to fix this problem? Thanks.

    Read the article

  • capture flash key event "escape"

    - by P..
    I have a flash site that users can view full Screen video. the trouble is, I am making only the video player full screen (hiding the rest of the site behind it). my "toggle full screen" button works in that it reduces the video player back to normal size when the user toggles out of full screen back. but when the user hits the escape key, my flash script doesn't know that the video player should be reduced in size. it seems there's no way to capture the ESCAPE key as a key event. any ideas?

    Read the article

  • Do you know of any alternative to "Google App Engine"?

    - by brilliant
    On their presentation of "Google App Engine" Google team members boldly said: "You write a code and we will run it for you". Then the "Google App Engine" was launched and it still does its job quite successfully - "Google App Engine" runs millions of applications of different sizes belonging to different users completely free!!! Now, here is the question: Do You know of any alternative to GAE? Have You ever even heard of any such service out there that would run Your Python code for free?

    Read the article

  • Jquery: How do I fire/play a sound file when I want?

    - by Sotkra
    I have some code that basically inflates a 'balloon' through 15 or so stages and then makes it pop at the 16th stage. (yes, images are changed). What I'm wondering now is if it's possible to use Jquery to play a sound file whenever I reach that 16th stage (or when whatever var reaches whatever value) - in other words...when I want. I've found several jquery sound plugins but they all create this player which I must then click for it to play the file. How do I skip that 'click' part so that the sound is just...directly/automatically played? http://www.sean-o.com/jquery/jmp3/ http://www.happyworm.com/jquery/jplayer/ All help is appreciated G.Campos

    Read the article

  • Runtime Error in asp.net site?

    - by Surya sasidhar
    hi, I developed a website in asp.net and i place the site in online. I upload my site in online by using CuteFTP. After uploading when i type my url it is giving error like this... Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off". Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >