Daily Archives

Articles indexed Wednesday May 5 2010

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

  • Modify values on-the-fly during SqlAdapter.Fill( )

    - by Timothy
    What would the proper way be to modify values on the fly as they are loaded into a DataTable by SqlAdapter.Fill()? I have globalized my application's log messages. An integer indicating the event type and serialized data relevant to the event is stored in the database as show below. When I display the logged events through a DataGridView control to the user, I interpolate the data to a formatting string. event_type event_timestamp event_details ============================================ 3 2010-05-04 20:49:58 jsmith 1 2010-05-04 20:50:42 jsmith ... I am currently iterating through the DataTable's rows to format the messages. public class LogDataTable : DataTable { public LogDataTable() { Locale = CultureInfo.CurrentCulture; Columns.AddRange(new DataColumn[] { new DataColumn("event_type", typeof(Int32)), new DataColumn("event_timestamp", typeof(DateTime)), new DataColumn("event_details", typeof(String))}); } } ... using (SqlDataAdapter adapter = new SqlDataAdapter(...)) { adapter.SelectCommand.Parameters.AddRange(new Object[] { ... }); adapter.Fill(table); } foreach (DataRow row in table.Rows) { switch ((LogEventType)row["event_type"]) { case LogEventType.Create: row["event_details"] = String.Format(Resources.Strings.LogEventCreateMsg, row["event_details"]; break; case LogEventType.Create: row["event_details"] = String.Format(Resources.Strings.LogEventCreateMsg, row["event_details"]; break; ... The end result as displayed would resemble: Type Date and Time Details ==================================================================== [icon] 2010-05-04 20:49:58 Failed login attempt with username jsmith [icon] 2010-05-04 20:50:42 Successful login with username jsmith ... It seems wasteful to iterate the result set twice-- once as the table is filled by the adapter, and again to perform the replacements. I would really like to do the replacement on-the-fly in my LogDataTable class as it is being populated. I have tried overriding an OnRowChanging method in LogDataTable, which throws an InRowChangingEventException. protected override void OnRowChanging(DataRowChangeEventArgs e) { base.OnRowChanging(e); switch ((LogEventType)row["event_type"]) ... I have tried overriding an OnRowChanged method, which throws a StackOverflowException (I assume changing it re-triggers the method ad infinitum?). I have tried overriding an OnTableNewRow method, which does not throw an exception but appears not to be invoked (I assume only when a user adds a row in the view, which I've prevented). I'd greatly appreciate any assistance anyone can give me.

    Read the article

  • C child read giving "resource temporarily unavailable"

    - by Gary
    So I have a file stream from a parent process to a child - and most of the time it works fine. However, when reading from it multiple times quickly, using fgets() will return NULL and the error is set to "resource temporarily unavailable". The problem is intermittent - and running the script that does the reads will sometimes have fgets return NULL and sometimes wont. Could anyone help me stop this error from happening? Thanks!

    Read the article

  • How to detect checkbox state in Javascript IE7

    - by justinl
    I have a simple checkbox on my website. Everytime you check and uncheck it, it shows an alert as to what the state is. This works flawlessly in FF, Chrome, and IE8. However, when I run this in IE7, no matter if the check is on or off, it always alerts "off". It's like IE7 can't detect that the checkbox is checked. Does anyone have an idea of how to fix this or work around it? I basically need to toggle the visibility of some content based on a checkbox, but IE7 is being difficult. Thanks! Here is my code that I'm using: function showHideTimeDropdown() { if (document.getElementById("input_checkbox").checked == true){ alert("on"); } else{ alert("off"); } }

    Read the article

  • Dissecting ASP.NET Routing

    The ASP.NET Routing framework allows developers to decouple the URL of a resource from the physical file on the web server. Specifically, the developer defines <i>routing rules</i>, which map URL patterns to a class or ASP.NET page that generates the content. For instance, you could create a URL pattern of the form <code>Categories/<i>CategoryName</i></code> and map it to the ASP.NET page <code>ShowCategoryDetails.aspx</code>; the <code>ShowCategoryDetails.aspx</code> page would display details about the category <i>CategoryName</i>. With such a mapping, users could view category about the Beverages category by visiting <code>www.yoursite.com/Categories/Beverages</code>. In short, ASP.NET Routing allows

    Read the article

  • Article Writing to Increase SEO

    Are you an affiliate marketer? Are you looking for a free way to get more traffic to your website? Article writing is one of the best ways to drive traffic to your website and help get your ranking up on the search engines.

    Read the article

  • SEO is Dead

    Search Engine Optimization (SEO) is a method businesses use to attempt to rise to the top of the results listings in Search Engines (SERPs). This has been a practice since search engines were invented for the Internet.

    Read the article

  • Robust Large File Transfer with WCF

    - by Sharov
    I want to transfer big files (1GB) over unreliable transport channels. When connection is interrupted, I don't want start file transfering from the begining. I can partially store it in a temp table and store last readed position, so when connection is reestablished I can request continue uploading of file from this position. Is there any best-practice for such kind of things. I'm currently use chunking channel.

    Read the article

  • Adding variably named fields to Python classes

    - by Carson Myers
    I have a python class, and I need to add an arbitrary number of arbitrarily long lists to it. The names of the lists I need to add are also arbitrary. For example, in PHP, I would do this: class MyClass { } $c = new MyClass(); $n = "hello" $c.$n = array(1, 2, 3); How do I do this in Python? I'm also wondering if this is a reasonable thing to do. The alternative would be to create a dict of lists in the class, but since the number and size of the lists is arbitrary, I was worried there might be a performance hit from this. If you are wondering what I'm trying to accomplish, I'm writing a super-lightweight script interpreter. The interpreter walks through a human-written list and creates some kind of byte-code. The byte-code of each function will be stored as a list named after the function in an "app" class. I'm curious to hear any other suggestions on how to do this as well.

    Read the article

  • How get divs count in jquery?

    - by Pandiya Chendur
    I used this jquery each function and iterated my json data with it.... $.each(data.Results, function() { divs += '<div class="resultsdiv"><br /> <span style="display: inline-block;width:150px;" class="resultName">' + this.Mat_Name + '</span><span class="resultfields" style="padding-left:10px;"> Measurement&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + this.Mes_Name + '</span>&nbsp;<a href="/Materials/Delete/' + this.Id + '"> Delete</a>&nbsp;<a href="/Materials/Details/' + this.Id + '">Details</a>&nbsp; <a href="/Materials/Edit/' + this.Id + '">Edit</a></div>'; }); alert(divs.length); doesnt seem to get the count.... Any suggestion...

    Read the article

  • How to backup data stored with Core Data - iPhone app?

    - by Alex
    I'm using sqlite for the persistent store, so could I just upload the .sqlite file to, for example, Amazon S3 as a way of providing users with the ability to backup their app data? Then for restoring just download it back and replace the existing .sqlite file in the app's folder. Does anybody see any issues with that? Has anyone done it? Any other suggestions on how to implement data backup feature?

    Read the article

  • PDO::fetchAll vs. PDO::fetch in a loop

    - by Byron
    Just a quick question. Is there any performance difference between using PDO::fetchAll() and PDO::fetch() in a loop (for large result sets)? I'm fetching into objects of a user-defined class, if that makes any difference. My initial uneducated assumption was that fetchAll might be faster because PDO can perform multiple operations in one statement while mysql_query can only execute one. However I have little knowledge of PDO's inner workings and the documentation doesn't say anything about this, and whether or not fetchAll() is simply a PHP-side loop dumped into an array. Any help?

    Read the article

  • read angles in radian and convert them in degrees/minutes/seconds

    - by Amadou
    n=0; disp('This program performs an angle conversion'); disp('input data set to a straight line. Enter the name'); disp('of the file containing the input Lambda in radian: '); filename = input(' ','s'); [fid,msg] = fopen(filename,'rt'); if fid < 0 disp(msg); else A=textscan(fid, '%g',1); while ~feof(fid) Lambda = A(1); n = n + 1; A = textscan(fid, '%f',1); end fclose(fid); end Alpha=Lambda*180/pi; fprintf('Angle converted from radian to degree/minutes/seconds:\n'); fprintf('Alpha =%12d\n',Alpha); fprintf('No of angles =%12d\n',n);

    Read the article

  • Create servlet from existing Java project

    - by user69514
    I have a Java Swing project for my class. I would like put it on my website so people can use it. However I'm not sure if there is a way to turn it into a servlet. Or do I need to know JavaScript? I'm confused. Is there a way to make my swing application into a servlet automatically?

    Read the article

  • Gridview rows blinking

    - by Bhavi
    Hi, I tried blink the rows of ASp:Gridview. Have succeded in IE but not working in FF and safari. FF error console says "Error: gridRef.childNodes is not a function" Can anybody tell me where exactly I am wrong... The Javascript used is: '); for (var i=0; i and on my gridview_rowdatabound I have e.Row.Attributes.Add("blinkingRow", "Y");

    Read the article

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