Search Results

Search found 1872 results on 75 pages for 'tom o'.

Page 32/75 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • SMO restore of SQL database doesn't overwrite

    - by Tom H.
    I'm trying to restore a database from a backup file using SMO. If the database does not already exist then it works fine. However, if the database already exists then I get no errors, but the database is not overwritten. The "restore" process still takes just as long, so it looks like it's working and doing a restore, but in the end the database has not changed. I'm doing this in Powershell using SMO. The code is a bit long, but I've included it below. You'll notice that I do set $restore.ReplaceDatabase = $true. Also, I use a try-catch block and report on any errors (I hope), but none are returned. Any obvious mistakes? Is it possible that I'm not reporting some error and it's being hidden from me? Thanks for any help or advice that you can give! function Invoke-SqlRestore { param( [string]$backup_file_name, [string]$server_name, [string]$database_name, [switch]$norecovery=$false ) # Get a new connection to the server [Microsoft.SqlServer.Management.Smo.Server]$server = New-SMOconnection -server_name $server_name Write-Host "Starting restore to $database_name on $server_name." Try { $backup_device = New-Object("Microsoft.SqlServer.Management.Smo.BackupDeviceItem") ($backup_file_name, "File") # Get local paths to the Database and Log file locations If ($server.Settings.DefaultFile.Length -eq 0) {$database_path = $server.Information.MasterDBPath } Else { $database_path = $server.Settings.DefaultFile} If ($server.Settings.DefaultLog.Length -eq 0 ) {$database_log_path = $server.Information.MasterDBLogPath } Else { $database_log_path = $server.Settings.DefaultLog} # Load up the Restore object settings $restore = New-Object Microsoft.SqlServer.Management.Smo.Restore $restore.Action = 'Database' $restore.Database = $database_name $restore.ReplaceDatabase = $true if ($norecovery.IsPresent) { $restore.NoRecovery = $true } Else { $restore.Norecovery = $false } $restore.Devices.Add($backup_device) # Get information from the backup file $restore_details = $restore.ReadBackupHeader($server) $data_files = $restore.ReadFileList($server) # Restore all backup files ForEach ($data_row in $data_files) { $logical_name = $data_row.LogicalName $physical_name = Get-FileName -path $data_row.PhysicalName $restore_data = New-Object("Microsoft.SqlServer.Management.Smo.RelocateFile") $restore_data.LogicalFileName = $logical_name if ($data_row.Type -eq "D") { # Restore Data file $restore_data.PhysicalFileName = $database_path + "\" + $physical_name } Else { # Restore Log file $restore_data.PhysicalFileName = $database_log_path + "\" + $physical_name } [Void]$restore.RelocateFiles.Add($restore_data) } $restore.SqlRestore($server) # If there are two files, assume the next is a Log if ($restore_details.Rows.Count -gt 1) { $restore.Action = [Microsoft.SqlServer.Management.Smo.RestoreActionType]::Log $restore.FileNumber = 2 $restore.SqlRestore($server) } } Catch { $ex = $_.Exception Write-Output $ex.message $ex = $ex.InnerException while ($ex.InnerException) { Write-Output $ex.InnerException.message $ex = $ex.InnerException } Throw $ex } Finally { $server.ConnectionContext.Disconnect() } Write-Host "Restore ended without any errors." }

    Read the article

  • C# SqlDataReader = null?

    - by tom
    myConnection.Open(); SqlDataReader myreader; myreader = SqlCom.ExecuteReader(); int id = -1; ErrorBox.InnerHtml = "Username:" + sUserName + ":" + sPassword + ":<br/>"; while (myreader.HasRows) { id = (int)myreader["id"]; String sUser = (String)myreader["Username"]; String sPass = (String)myreader["Password"]; ErrorBox.InnerHtml += "UserId is <b>" + id + "</b> " + sUser + ":" + sPass + ":<br >"; Session["LoginID"] = id; Server.Transfer(ReturnPage); } if (id == -1) { ErrorBox.InnerHtml = "Incorrect Password"; } myConnection.Close(); I added a breakpoint at myreader = SqlCom.ExecuteReader(); and it keeps returning myreader as null and HasRows = False, but it does have rows. So, it keeps validating my login as incorrect since id = -1, Help?

    Read the article

  • How to recall search pattern when writing replace regex pattern in Vim?

    - by Tom Morris
    Here's the scenario: I've got a big file filled with all sorts of eclectic rubbish that I want to regex. I fiddle around and come up with a perfect search pattern by using the / command and seeing what it highlights. Now I want to use that pattern to replace with. So, I start typing :%s/ and I cannot recall what the pattern was. Is there some magical keyboard command that will pull in my last search pattern here? If I'm writing a particularly complex regex, I have even opened up a new MacVim window, typed the regex from the first window into a buffer there, then typed it back into the Vim window when writing the replace pattern. There has got to be a better way of doing so.

    Read the article

  • How do you automap List<float> or float[] with Fluent NHibernate?

    - by Tom Bushell
    Having successfully gotten a sample program working, I'm now starting to do Real Work with Fluent NHibernate - trying to use Automapping on my project's class heirarchy. It's a scientific instrumentation application, and the classes I'm mapping have several properties that are arrays of floats e.g. private float[] _rawY; public virtual float[] RawY { get { return _rawY; } set { _rawY = value; } } These arrays can contain a maximum of 500 values. I didn't expect Automapping to work on arrays, but tried it anyway, with some success at first. Each array was auto mapped to a BLOB (using SQLite), which seemed like a viable solution. The first problem came when I tried to call SaveOrUpdate on the objects containing the arrays - I got "No persister for float[]" exceptions. So my next thought was to convert all my arrays into ILists e.g. public virtual IList<float> RawY { get; set; } But now I get: NHibernate.MappingException: Association references unmapped class: System.Single Since Automapping can deal with lists of complex objects, it never occured to me it would not be able to map lists of basic types. But after doing some Googling for a solution, this seems to be the case. Some people seem to have solved the problem, but the sample code I saw requires more knowledge of NHibernate than I have right now - I didn't understand it. Questions: 1. How can I make this work with Automapping? 2. Also, is it better to use arrays or lists for this application? I can modify my app to use either if necessary (though I prefer lists). Edit: I've studied the code in Mapping Collection of Strings, and I see there is test code in the source that sets up an IList of strings, e.g. public virtual IList<string> ListOfSimpleChildren { get; set; } [Test] public void CanSetAsElement() { new MappingTester<OneToManyTarget>() .ForMapping(m => m.HasMany(x => x.ListOfSimpleChildren).Element("columnName")) .Element("class/bag/element").Exists(); } so this must be possible using pure Automapping, but I've had zero luck getting anything to work, probably because I don't have the requisite knowlege of manually mapping with NHibernate. Starting to think I'm going to have to hack this (by encoding the array of floats as a single string, or creating a class that contains a single float which I then aggregate into my lists), unless someone can tell me how to do it properly. End Edit Here's my CreateSessionFactory method, if that helps formulate a reply... private static ISessionFactory CreateSessionFactory() { ISessionFactory sessionFactory = null; const string autoMapExportDir = "AutoMapExport"; if( !Directory.Exists(autoMapExportDir) ) Directory.CreateDirectory(autoMapExportDir); try { var autoPersistenceModel = AutoMap.AssemblyOf<DlsAppOverlordExportRunData>() .Where(t => t.Namespace == "DlsAppAutomapped") .Conventions.Add( DefaultCascade.All() ) ; sessionFactory = Fluently.Configure() .Database(SQLiteConfiguration.Standard .UsingFile(DbFile) .ShowSql() ) .Mappings(m => m.AutoMappings.Add(autoPersistenceModel) .ExportTo(autoMapExportDir) ) .ExposeConfiguration(BuildSchema) .BuildSessionFactory() ; } catch (Exception e) { Debug.WriteLine(e); } return sessionFactory; }

    Read the article

  • Success function not being called when form is submitted. jQuery / validationEngine / PHP form proce

    - by Tom Hartman
    Hi, I've been trying to figure out why the following script's success function isn't running. Everything in my form works perfectly, and the form contents are being emailed correctly, but the success function isn't being called. If anyone could review my code and let me know why my success function isn't being called I would very much appreciate it! Here is the HTML form with notification divs, which are hidden via css: <div id="success" class="notification"> <p>Thank you! Your message has been sent.</p> </div> <div id="failure" class="notification"> <p>Sorry, your message could not be sent.</p> </div> <form id="contact-form" method="post" action="" class="jqtransform"> <label for="name">Name:</label> <input name="name" id="name" type="text" class="validate[required] input" /> <label for="company">Company:</label> <input name="company" id="company" type="text" class="input" /> <label for="phone">Phone:</label> <input name="phone" id="phone" type="text" class="input" /> <label for="email">Email:</label> <input name="email" id="email" type="text" class="validate[required,email] input" /> <div class="sep"></div> <label for="subject">Subject:</label> <input name="subject" id="subject" type="text" class="validate[required] input" /> <div class="clear"></div> <label for="message">Message:</label> <textarea name="message" id="message" class="validate[required]"></textarea> <div id="check-services"> <input type="checkbox" name="services[]" value="Contractor Recommendation" /> <div>Contractor Recommendation</div> <input type="checkbox" name="services[]" value="Proposal Review" /> <div>Proposal Review</div> <input type="checkbox" name="services[]" value="Existing Website Review" /> <div>Existing Website Review</div> <input type="checkbox" name="services[]" value="Work Evaluation" /> <div>Work Evaluation</div> <input type="checkbox" name="services[]" value="Layman Translation" /> <div>Layman Translation</div> <input type="checkbox" name="services[]" value="Project Management" /> <div>Project Management</div> </div> <div class="sep"></div> <input name="submit" id="submit" type="submit" class="button" value="Send" /> <input name="reset" id="reset" type="reset" class="button" value="Clear" onclick="$.validationEngine.closePrompt('.formError',true)" /> </form> Here is the javascript: // CONTACT FORM VALIDATION AND SUBMISSION $(document).ready(function(){ $('#contact-form').validationEngine({ ajaxSubmit: true, ajaxSubmitFile: 'lib/mail.php', scroll: false, success: function(){ $('#success').slideDown(); }, failure: function(){ $('#failure').slideDown(); $('.formError').animate({ marginTop: '+30px' }); } }); }); And here is my PHP mailer script: <?php $name = $_POST['name']; $company = $_POST['company']; $phone = $_POST['phone']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $services = $_POST['services']; $to = '[email protected]'; $subject = 'THC - Contact'; $content .= "You received a message from ".$name.".\r\n\n"; if ($company): $content .= "They work for ".$company.".\r\n\n"; endif; $content .= "Here's the message:\r\n\n".$message."\r\n\n"; $content .= "And they are interested in the services below:\r\n\n"; $content .= implode("\r\n",$services); if ($phone): $content .= "\r\n\nYou can reach them at ".$phone."."; else: $content .= "\r\n\nNo phone number was provided."; endif; $headers = "From: ".$name."\r\n"; $headers .= "Reply-To: ".$email."\r\n"; if (mail($to,$subject,$content,$headers)): return true; else: return false; endif; ?>

    Read the article

  • FindBugs controversial description

    - by Tom Brito
    Am I understanding it wrong, or is the description wrong? Equals checks for noncompatible operand (EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS) This equals method is checking to see if the argument is some incompatible type (i.e., a class that is neither a supertype nor subtype of the class that defines the equals method). For example, the Foo class might have an equals method that looks like: public boolean equals(Object o) { if (o instanceof Foo) return name.equals(((Foo)o).name); else if (o instanceof String) return name.equals(o); else return false; This is considered bad practice, as it makes it very hard to implement an equals method that is symmetric and transitive. Without those properties, very unexpected behavoirs are possible. From: http://findbugs.sourceforge.net/bugDescriptions.html#EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS The description says that the Foo class might have an equals method like that, and after it says that "This is considered bad practice". I'm not getting the "right way".. How should the following method be to be right? @Override public boolean equals(Object obj) { if (obj instanceof DefaultTableModel) return model.equals((DefaultTableModel)obj); else return false; }

    Read the article

  • iPhone: How to detect if an EKEvent instance can be modified?

    - by Tom van Zummeren
    While working with the EventKit on iPhone I noticed that some events can exist which cannot be modified. Examples I encountered so far are birthdays and events synced with CalDAV. When you view the event's details in the standard built-in calendar app on iPhone the "Edit" button in the top-right corner is not visible in these cases, where it would be visible when viewing "normal" events. I've searched everywhere, read all documentation there is but I simply can't find anything that tells me how to detect this behavior! I can only detect it afterwards: edit an event's title save it to the event store check the event's title, if it has not changed it is not editable! I am looking for a way that I can detect the non-editable behavior of an event beforehand. I know this is possible because I've seen other calendar apps implement this correctly.

    Read the article

  • How to Get JSF 2.0 Working with Eclipse 3.5 and JBoss 5.1

    - by Tom Tresansky
    I am running Eclipse 3.5 and JBoss 5.1. I want to create a JSF 2.0 project. I heard here that the Eclipse JBoss Tools plugin version 3.1 (available here) could do this for me. I have installed the plugin. However, if I go to the Project Facets properties page for a Dynamic Web Project, I only see Facets for JavaServer Faces 1.1 and 1.2. My Java facet is set at 6.0, and my Dynamic Web Module to 2.5. In the Targeted Runtimes properties page, I see that I am targeting the JBoss 5.1 Runtime. I understand that Eclipse Helios will be here next week, but I'm curious if its possible to get JSF 2.0 working with 3.5. Any thoughts?

    Read the article

  • Eclipse CDT: Import source / header files into my new project, without duplicating them

    - by Tom
    Hi all, Im sure there is a very simple solution for this. I have a bunch of .cpp / .h files from a project, say in directory ~/files On the other hand, I want to create a c++ project using eclipse to work on those files, so I put my workspace on ~/wherever. Then I create a c++ project: ~/wherever/project, and include the source files (located in /~files). The problem i'm having is that files are now duplicated in ~/wherever/project, and I would like to avoid that, specially so I know which copy of the file to commit. Is this possible? Im sure it is, but cant get it. Thanks in advance.

    Read the article

  • Setup GIT Server with Msysgit on Windows

    - by Tom
    Hi Guys, My friends and I are trying to setup GIT for windows using this tutorial but we just keep running into problems. I know many of you guys on this site are GIT gurus - so I was wondering whether anyone would be able to help us (and I am sure 100s of other Windows Devs who want to use GIT) write a "Setup GIT Server" guide for windows using Msysgit ? There is a comment on the guide above suggesting it cant be done with Msysgit because gitosis requires the use of an SSH Server and Bash ? Would really appreciate it if someone could do a step by step guide as there is not one available (we've search for hours)? Install Mysisgit ? Thx

    Read the article

  • SugarCRM installation frozen

    - by Tom S.
    Hi there. I'm trying to install SugarCRM version 5.5.1. on a webhost. Everything goes nice until the step when the installation begins. The output is this one: Creating Sugar configuration file (config.php) Creating Sugar application tables, audit tables and relationship metadata ............. And never moves on! I check the database and can see that there are tables missing. The install.log file doesnt have any errors, and the last line in the file is: 2010-04-27 22:17:03...creating Relationship Meta for Bug It seems the installation stopped here, but i cant get why! Iv searched in the foruns, etc, but cant get it... Anyone had this issue? Any clues about whats happening? Thanks a lot

    Read the article

  • JSINQ (Linq for JavaScript library) sub-queries (how-to)

    - by Tom Tresansky
    I'm using this library: jsinq. I want to create a new object using subqueries. For example, in .NET LINQ, I could do something like this: from a in Attendances where a.SomeProperty = SomeValue select new { .Property1 = a.Property1, .Property2 = a.Property2, .Property3 = (from p in People where p.SomeProperty = a.Property3 select p) } such that I get a list of ALL people where Property3 value matches the attendance's Property3 value in EACH object returned in the list. I didn't see any sample of this in the docs or on the playground. Made a couple tries of it and didn't have any luck. Anybody know if this is possible and how to?

    Read the article

  • Running Command via Java ProccesBuilder Different to Running the same in the Shell

    - by Tom Duckering
    I'm tearing my hair out trying to work out why the command I'm executing via Java using a ProcessBuilder & Process is not working. I run the "same" command at the Windows command line and it works as expected. It must be that they're not the same but I can't for the life of me work out why. The command is this: ccm start -nogui -m -q -n ccm_admin -r developer -d /path/to/db/databasename -s http://hostname:8400 -pw Passw0rd789$ The output is should be a single line string that I need to grab and set as an environment variable (hence the v. basic use of the BufferedReader). My Java code, which when it runs the command gets an application error, looks like this with entry point being startCCMAndGetCCMAddress(): private static String ccmAddress = ""; private static final String DATABASE_PATH = "/path/to/db/databasename"; private static final String SYNERGY_URL = "http://hostname:8400"; private static final String USERNAME = "ccm_admin"; private static final String PASSWORD = "Passw0rd789$"; private static final String USER_ROLE = "developer"; public static List<String> getCCMStartCommand() { List<String> command = new ArrayList<String>(); command.add("cmd.exe"); command.add("/C"); command.add("ccm"); command.add("start"); command.add("-nogui"); command.add("-m"); command.add("-q"); command.add("-n "+USERNAME); command.add("-r "+USER_ROLE); command.add("-d "+DATABASE_PATH); command.add("-s "+SYNERGY_URL); command.add("-pw "+PASSWORD); return command; } private static String startCCMAndGetCCMAddress() throws IOException, CCMCommandException { int processExitValue = 0; List<String> command = getCCMStartCommand(); System.err.println("Will run: "+command); ProcessBuilder procBuilder = new ProcessBuilder(command); procBuilder.redirectErrorStream(true); Process proc = procBuilder.start(); BufferedReader outputBr = new BufferedReader(new InputStreamReader(proc.getInputStream())); try { proc.waitFor(); } catch (InterruptedException e) { processExitValue = proc.exitValue(); } String outputLine = outputBr.readLine(); outputBr.close(); if (processExitValue != 0) { throw new CCMCommandException("Command failed with output: " + outputLine); } if (outputLine == null) { throw new CCMCommandException("Command returned zero but there was no output"); } return outputLine; } The output of the System.err.println(...) is: Will run: [cmd.exe, /C, ccm, start, -nogui, -m, -q, -n ccm_admin, -r developer, -d /path/to/db/databasename, -s http://hostname:8400, -pw Passw0rd789$]

    Read the article

  • Running multiple image manipulations in parallel causing OutOfMemory exception

    - by Tom
    I am working on a site where I need to be able to split and image around 4000x6000 into 4 parts (amongst many other tasks) and I need this to be as quick as possible for multiple users. My current code for doing this is var bitmaps = new RenderTargetBitmap[elements.Length]; using (var stream = blobService.Stream(key)) { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = stream; bi.EndInit(); for (var i = 0; i < elements.Length; i++) { var element = elements[i]; TransformGroup transformGroup = new TransformGroup(); TranslateTransform translateTransform = new TranslateTransform(); translateTransform.X = -element.Left; translateTransform.Y = -element.Top; transformGroup.Children.Add(translateTransform); DrawingVisual vis = new DrawingVisual(); DrawingContext cont = vis.RenderOpen(); cont.PushTransform(transformGroup); cont.DrawImage(bi, new Rect(new Size(bi.PixelWidth, bi.PixelHeight))); cont.Close(); RenderTargetBitmap rtb = new RenderTargetBitmap(element.Width, element.Height, 96d, 96d, PixelFormats.Default); rtb.Render(vis); bitmaps[i] = rtb; } } for (var i = 0; i < bitmaps.Length; i++) { using (MemoryStream ms = new MemoryStream()) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmaps[i])); encoder.Save(ms); var regionKey = WebPath.Variant(key, elements[i].Id); saveBlobService.Save("image/png", regionKey, ms); } } I am running multiple threads which take jobs off a queue. I am finding that if this part of code is hit by 4 threads at once I get an OutOfMemory exception. I can stop this happening by wrapping all the code above in a lock(obj) but this isn't ideal. I have tried wrapping just the first using block (where the file is read from disk and split) but I still get the out of memory exceptions (this part of the code executes quite quickly). I this normal considering the amount of memory this should be taking up? Are there any optimisations I could make? Can I increase the memory available? UPDATE: My new code as per Moozhe's help public static void GenerateRegions(this IBlobService blobService, string key, Element[] elements) { using (var stream = blobService.Stream(key)) { foreach (var element in elements) { stream.Position = 0; BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.SourceRect = new Int32Rect(element.Left, element.Top, element.Width, element.Height); bi.StreamSource = stream; bi.EndInit(); DrawingVisual vis = new DrawingVisual(); DrawingContext cont = vis.RenderOpen(); cont.DrawImage(bi, new Rect(new Size(element.Width, element.Height))); cont.Close(); RenderTargetBitmap rtb = new RenderTargetBitmap(element.Width, element.Height, 96d, 96d, PixelFormats.Default); rtb.Render(vis); using (MemoryStream ms = new MemoryStream()) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(rtb)); encoder.Save(ms); var regionKey = WebPath.Variant(key, element.Id); blobService.Save("image/png", regionKey, ms); } } } }

    Read the article

  • How to get target element of keypress in designmode iframe

    - by Tom
    Is it possible to get the target element in a keypress event handler in a design mode iframe ? I know it can be done in the mousedown event handler (by accessing event.target), but in the keypress / keydown handlers event.target is always the iframe element. For example, with the following html, if the user types into the div where it says * key press here *, I would like in the keypress / keydown event handler to be able to determine that the target element is the div with id='b'. Is this possible ? <div id='a'> <div id='b'> *** Key press here *** </div> </div>

    Read the article

  • Managing data charts

    - by Tom Gullen
    My dbml file is just getting bigger and bigger and more unwieldy: I favoured an all-in-one approach as supposed to multiple data contexts because when I tried that it was near impossible to manage in code. I was advised it was better to have them all in one chart and the difficulty will be simply in managing this chart and not in code. The chart I've got is becoming a pain to manage, if I want to even remove a table and re-add it it sometimes takes a little while to manually find it! There isn't even a list I can find in VS2010 of the objects you have in that chart! Is there a better way of doing this?

    Read the article

  • How to increment variable names/Is this a bad idea

    - by tom
    In Python, if I were to have a user input the number X, and then the program enters a for loop in which the user inputs X values, is there a way/is it a bad idea to have variable names automatically increment? ie: user inputs '6' value_1 = ... value_2 = ... value_3 = ... value_4 = ... value_5 = ... value_6 = ... Can I make variable names increment like that so that I can have the number of variables that the user inputs? Or should I be using a completely different method such as appending all the new values onto a list?

    Read the article

  • WiX: Installing Service as LocalService

    - by Tom the Junglist
    Hey there, I am trying to get my application an installer via WiX 3.0. The exact code is: <File Id="ServiceComponentMain" Name="$(var.myProgramService.TargetFileName)" Source="$(var.myProgramService.TargetPath)" DiskId="1" Vital="yes"/> <!-- service will need to be installed under Local Service --> <ServiceInstall Id="MyProgramServiceInstaller" Type="ownProcess" Vital="yes" Name="MyProgramAddon" DisplayName="[removed]" Description="[removed]" Start="auto" Account="LocalService" ErrorControl="ignore" Interactive="no"/> <ServiceControl Id="StartDDService" Name="MyProgramServiceInstaller" Start="install" Wait="no" /> <ServiceControl Id="StopDDService" Name="MyProgramServiceInstaller" Stop="both" Wait="yes" Remove="uninstall" /> Thing is, for some reason LocalService fails on the "Installing services" step, and if I change it to "LocalSystem" then the installer times out while trying to start the service. The service starts fine manually and at system startup, and for all intents and purposes works great. I've heard there are issues getting services to work right under LocalService, but Google isnt really helping as everyone's responses have been "got it to work kthx". Just looking to get this service set up and started during installation, that's all. Any help? Thanks!

    Read the article

  • What is it about DataTable Column Names with dots that makes them unsuitable for WPF's DataGrid cont

    - by Tom Ritter
    Run this, and be confused: <Window x:Class="Fucking_Data_Grids.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <StackPanel> <DataGrid Name="r1" ItemsSource="{Binding Path=.}"> </DataGrid> <DataGrid Name="r2" ItemsSource="{Binding Path=.}"> </DataGrid> </StackPanel> </Window> Codebehind: using System.Data; using System.Windows; namespace Fucking_Data_Grids { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DataTable dt1, dt2; dt1 = new DataTable(); dt2 = new DataTable(); dt1.Columns.Add("a-name", typeof(string)); dt1.Columns.Add("b-name", typeof(string)); dt1.Rows.Add(new object[] { 1, "Hi" }); dt1.Rows.Add(new object[] { 2, "Hi" }); dt1.Rows.Add(new object[] { 3, "Hi" }); dt1.Rows.Add(new object[] { 4, "Hi" }); dt1.Rows.Add(new object[] { 5, "Hi" }); dt1.Rows.Add(new object[] { 6, "Hi" }); dt1.Rows.Add(new object[] { 7, "Hi" }); dt2.Columns.Add("a.name", typeof(string)); dt2.Columns.Add("b.name", typeof(string)); dt2.Rows.Add(new object[] { 1, "Hi" }); dt2.Rows.Add(new object[] { 2, "Hi" }); dt2.Rows.Add(new object[] { 3, "Hi" }); dt2.Rows.Add(new object[] { 4, "Hi" }); dt2.Rows.Add(new object[] { 5, "Hi" }); dt2.Rows.Add(new object[] { 6, "Hi" }); dt2.Rows.Add(new object[] { 7, "Hi" }); r1.DataContext = dt1; r2.DataContext = dt2; } } } I'll tell you what happens. The top datagrid is populated with column headers and data. The bottom datagrid has column headers but all the rows are blank.

    Read the article

  • python - tkinter - update label from variable

    - by Tom
    I wrote a python script that does some stuff to generate and then keep changing some text stored as a string variable. This works, and I can print the string each time it gets changed. Problems have arisen while trying to display that output in a GUI (just as a basic label) using tkinter. I can get the label to display the string for the first time... but it never updates. This is really the first time I have tried to use tkinter, so it's likely I'm making a foolish error. What I've got looks logical to me, but I'm evidently going wrong somewhere! from tkinter import * outputText = 'Ready' counter = int(0) root = Tk() root.maxsize(400, 400) var = StringVar() l = Label(root, textvariable=var, anchor=NW, justify=LEFT, wraplength=398) l.pack() var.set(outputText) while True: counter = counter + 1 #do some stuff that generates string as variable 'result' outputText = result #do some more stuff that generates new string as variable 'result' outputText = result #do some more stuff that generates new string as variable 'result' outputText = result if counter == 5: break root.mainloop() I also tried: from tkinter import * outputText = 'Ready' counter = int(0) root = Tk() root.maxsize(400, 400) var = StringVar() l = Label(root, textvariable=var, anchor=NW, justify=LEFT, wraplength=398) l.pack() var.set(outputText) while True: counter = counter + 1 #do some stuff that generates string as variable 'result' outputText = result var.set(outputText) #do some more stuff that generates new string as variable 'result' outputText = result var.set(outputText) #do some more stuff that generates new string as variable 'result' outputText = result var.set(outputText) if counter == 5: break root.mainloop() In both cases, the label will show 'Ready' but won't update to change that to the strings as they're generated later. After a fair bit of googling and looking through answers on this site, I thought the solution might be to use update_idletasks - I tried putting that in after each time the variable was changed, but it didn't help. It also seems possible I am meant to be using trace and callback somehow to make all this work...but I can't get my head around how that works (I tried, but didn't manage to make anything that even looked like it would do something, let alone actually worked). I'm still very new to both python and especially tkinter, so, any help much appreciated but please spell it out for me if you can :)

    Read the article

  • Adding a sortcomparefunction to Dynamic Data Grid in flex

    - by Tom
    Hi, I am trying to create a dynamic datagrid in Flex 3, I have a list of columns a list of objects which correspond to datapoints for those columns which I fetch from a url. While the grid works perfectly fine the problem is that sorting on the columns is done in lexical order. I am aware that this can be fixed by adding a sortcomparefunction to a column, which is not easy for this case. I have tried doing var dgc:DataGridColumn = new DataGridColumn(dtf); f1[dtf] = function(obj1:Object, obj2:Object):int { return Comparators.sortNumeric(obj1[dtf],obj2[dtf]); }; dgc.sortCompareFunction = f1[dtf];` But the problem is that the function object that I am creating here is being overwritten in every iteration (as I am adding columns) and eventually all the columns will have sorting done only on the last column added. Suggestions please.

    Read the article

  • Canvas rotate from bottom center image angle?

    - by Tom
    How do you rotate an image with the canvas html5 element from the bottom center angle? See http://uptowar.com/test.php for my current code and image: <html> <head> <title>test</title> <script type="text/javascript"> function startup() { var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); var img = new Image(); img.src = 'player.gif'; img.onload = function() { ctx.translate(185, 185); ctx.rotate(90 * Math.PI / 180); ctx.drawImage(img, 0, 0, 64, 120); } } </script> </head> <body onload='startup();'> <canvas id="canvas" style="position: absolute; left: 300px; top: 300px;" width="800" height="800"></canvas> </body> </html> Unfortunately this seems to rotate it from the top left angle of the image. Any idea? Edit: in the end the object (space ship) has to rotate like a clock pointer, as if it is turning right/left.

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >