Daily Archives

Articles indexed Friday June 11 2010

Page 12/114 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Does EF 4 Code First's ContextBuilder Dispose its SqlConnection?

    - by Eric J.
    Looking at Code First in ADO.Net EF 4 CTP 3 and wondered how the SqlConnection in their walkthrough is disposed. Is that the responsibility of ContextBuilder? Is it missing from the example? var connection = new SqlConnection(DB_CONN); var builder = new ContextBuilder<BloggingModel>(); var connection = new SqlConnection(DB_CONN); using (var ctx = builder.Create(connection)) { //... }

    Read the article

  • How come my red border is not wrapping around my text div and my side bar div

    - by Clay
    How come my red border is not wrapping around my text div and my side bar div. Here's my code: CSS: body{ background-color: #d7d7d7; color: #666666; font-family: arial, sans-serif; font-size: x-small; } div#header { background-color: #323232; height: 140px; width: 950px; } div#maincontainer { background-color: #d7d7d7; width: 950px; height: auto; margin-top: 5px; border: 1px solid red; } div#maintextcontainer{ //background-color: #333333; width: 640px; //margin-right: 10px; margin: 1px; float: left; color: black; } div#maintextcontainer h2{ color: #4f4f4f; } div#sidebarcontainer { //background-color: #333333; width: 300px; float: left; color: black; margin: 1px; } div#footer{ background-color: #323232; width: 950px; margin-top: 5px; clear: left; } div#global{ width: 950px; margin: auto; } HTML: <div id="global"> <div id="header"> This is the header div</div> <div id="maincontainer"> <div id="maintextcontainer">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi aliquam neque eu turpis euismod eget suscipit nulla ultrices. Donec sagittis mi non sem vestibulum elementum dapibus risus auctor. Praesent tristique laoreet dapibus. Integer vel ligula lorem, et pharetra lorem. </div> <div id="sidebarcontainer">Nam at lectus vitae est tempor lacinia sed et ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent interdum mi id nisi aliquet pulvinar. </div> </div> <div id="footer">This is Footer Text</div> </div>

    Read the article

  • PostgreSQL triggers and passing parameters

    - by iandouglas
    This is a multi-part question. I have a table similar to this: CREATE TABLE sales_data ( Company character(50), Contract character(50), top_revenue_sum integer, top_revenue_sales integer, last_sale timestamp) ; I'd like to create a trigger for new inserts into this table, something like this: CREATE OR REPLACE FUNCTION add_contract() RETURNS VOID DECLARE myCompany character(50), myContract character(50), BEGIN myCompany = TG_ARGV[0]; myContract = TG_ARGV[1]; IF (TG_OP = 'INSERT') THEN EXECUTE 'CREATE TABLE salesdata_' || $myCompany || '_' || $myContract || ' ( sale_amount integer, updated TIMESTAMP not null, some_data varchar(32), country varchar(2) ) ;' EXECUTE 'CREATE TRIGGER update_sales_data BEFORE INSERT OR DELETE ON salesdata_' || $myCompany || '_' || $myContract || ' FOR EACH ROW EXECUTE update_sales_data( ' || $myCompany || ',' || $myContract || ', revenue);' ; END IF; END; $add_contract$ LANGUAGE plpgsql; CREATE TRIGGER add_contract AFTER INSERT ON sales_data FOR EACH ROW EXECUTE add_contract() ; Basically, every time I insert a new row into sales_data, I want to generate a new table where the name of the table will be defined as something like "salesdata_Company_Contract" So my first question is how can I pass the Company and Contract data to the trigger so it can be passed to the add_contract() stored procedure? From my stored procedure, you'll see that I also want to update the original sales_data table whenever new data is inserted into the salesdata_Company_Contract table. This trigger will do something like this: CREATE OR REPLACE FUNCTION update_sales_data() RETURNS trigger as $update_sales_data$ DECLARE myCompany character(50) NOT NULL, myContract character(50) NOT NULL, myRevenue integer NOT NULL BEGIN myCompany = TG_ARGV[0] ; myContract = TG_ARGV[1] ; myRevenue = TG_ARGV[2] ; IF (TG_OP = 'INSERT') THEN UPDATE sales_data SET top_revenue_sales = top_revenue_sales + 1, top_revenue_sum = top_revenue_sum + $myRevenue, updated = now() WHERE Company = $myCompany AND Contract = $myContract ; ELSIF (TG_OP = 'DELETE') THEN UPDATE sales_data SET top_revenue_sales = top_revenue_sales - 1, top_revenue_sum = top_revenue_sum - $myRevenue, updated = now() WHERE Company = $myCompany AND Contract = $myContract ; END IF; END; $update_sales_data$ LANGUAGE plpgsql; This will, of course, require that I pass several parameters around within these stored procedures and triggers, and I'm not sure (a) if this is even possible, or (b) practical, or (c) best practice and we should just put this logic into our other software instead of asking the database to do this work for us. To keep our table sizes down, as we'll have hundreds of thousands of transactions per day, we've decided to partition our data using the Company and Contract strings as part of the table names themselves so they're all very small in size; file IO for us is faster and we felt we'd get better performance. Thanks for any thoughts or direction. My thinking, now that I've written all of this out, is that maybe we need to write stored procedures where we pass our insert data as parameters, and call that from our other software, and have the stored procedure do the insert into "sales_data" then create the other table. Then, have a second stored procedure to insert new data into the salesdata_Company_Contract tables, where the table name is passed to the stored proc as a parameter, and again have that stored proc do the insert, then update the main sales_data table afterward. What approach would you take?

    Read the article

  • Localizing MVVM based WPF applications

    - by bitbonk
    What would be a good aproach to localize a MVVM based WPF allication that can change its language at runtime? Of course I could create a string property in the ViewModel for each and every string that is displayed somewhere in the View but that seems rather tedious to me. Is there a common approach/best practice for this?

    Read the article

  • Problem while configuring the file Delimeter("\t") in app.config(C#3.0)

    - by Newbie
    In my app.config file I made the setting like the following <add key = "Delimeter" value ="\t"/> Now while accessing the above from the program by using the below code string delimeter = ConfigurationManager.AppSettings["FileDelimeter"].ToString(); StreamWriter streamWriter = null; streamWriter = new StreamWriter(fs); streamWriter.BaseStream.Seek(0, SeekOrigin.End); Enumerable .Range(0, outData.Length) .ToList().ForEach(i => streamWriter.Write(outData[i].ToString() + delimiter)); streamWriter.WriteLine(); streamWriter.Flush(); I am getting the output as 18804\t20100326\t5.59975381254617\t 18804\t20100326\t1.82599797249479\t But if I directly use "\t" in the delimeter variable I am getting the correct output 18804 20100326 5.59975381254617 18804 20100326 1.82599797249479 I found that while I am specifying the "\t" in the config file, and while reading it into the delimeter variable, it is becoming "\\t" which is the problem. I even tried with but with no luck. I am using C#3.0. Need help

    Read the article

  • Change Cursor for Netbeans on Linux

    - by Daziplqa
    Hi, I am recently have been successfully installed NetBean 6.8 on Ubuntu Box (10.04). But the problem is, NetBeans doesn't use the Gnome mouse Cursor by default. instead, It uses some freak mouse cursor that I hate! So, do you have any idea about how to change the cursor that appears inside netbeans.(I have looked inside tools options but without any output) Also I have did: $ grep -iR cursor * Binary file var/cache/all-resources.dat matches Binary file var/cache/all-layers.dat matches Binary file var/cache/index/s2/javascript/8/1/_0.cfs matches (note, I didn't talked here about how to change the cursor inside some Java program written in NetBeans) Thanks in advance.

    Read the article

  • tsql getdate conversion

    - by Manjot
    Hi, I know that when i do the following, it converts getdate to int select cast (getdate() as int) Getdate output on my server is "2010-06-11 14:42:20.100" and the int to which the above command is converting to is 40339. What is this integer? Did this int consider minutes and seconds? i am confused. Please help. Regards Manjot

    Read the article

  • Can I ensure all tests contain an assertion in test/unit?

    - by Andrew Grimm
    With test/unit, and minitest, is it possible to fail any test that doesn't contain an assertion, or would monkey-patching be required (for example, checking if the assertion count increased after each test was executed)? Background: I shouldn't write unit tests without assertions - at a minimum, I should use assert_nothing_raised if I'm smoke testing to indicate that I'm smoke testing. Usually I write tests that fail first, but I'm writing some regression tests. Alternatively, I could supply an incorrect expected value to see if the test is comparing the expected and actual value.

    Read the article

  • Getting name of active wireless network iOS 3.1/3.2

    - by Typeoneerror
    Looking for a way to get the name of the wireless network the iPhone/Touch is connected to within my application. Is there a simple way to do that? I need to be able to notify users that they need to be on the same network as another Peer via GameKit. So, second question. Any chance I could see a list of available networks and names of peers connected to those?

    Read the article

  • SQL SERVER Difference Between DATETIME and DATETIME2

    Yesterday I have written a very quick blog post on SQL SERVER Difference Between GETDATE and SYSDATETIME and I got tremendous response for the same. I suggest you read that blog post before continuing this blog post today. I had asked people to honestly take part and share their view about above two system [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Open XML at TechEd 2010

    Open XML was a big part of my first session at TechEd 2010 called, "Office 2010: Developing the Next Wave of Productivity Solutions". The thing that gets the biggest reaction is the Open XML SDK 2.0 "Productivity Tool"-- especially the ability to reflect over an Office document to produce C# code that will produce the target document. Here's the scenario: I have a Word document (Excel spreadsheet, PowerPoint deck) that a user produced manually. I want to be able to produce that same document...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Is "map" a loop?

    - by DVK
    While answering this question, I came to realize that I was not sure whether Perl's map can be considered a loop or not? On one hand, it quacks/walks like a loop (does O(n) work, can be easily re-written by an equivalent loop, and sort of fits the common definition = "a sequence of instructions that is continually repeated"). On the other hand, map is not usually listed among Perl's control structures, of which loops are a subset of. E.g. http://en.wikipedia.org/wiki/Perl_control_structures#Loops So, what i'm looking for is a formal reason to be convinced of one side vs. the other. So far, the former (it is a loop) sounds a lot more convincing to me, but I'm bothered by the fact that I never saw "map" mentioned in a list of Perl loops.

    Read the article

  • asp.net postback with jquery?

    - by mark smith
    Hi there, Can anyone help, I have a asp.net button but recently replaced it with a standard html button ... What i need to do is postback to an asp.net page and ensure a method is called the button before was an asp.net button so i had this event Protected Sub btnCancelar_Click(ByVal sender As Object, ByVal e As System.EventArgs) UtilTMP.DisposeObjects() Server.Transfer("~\Forms\test.aspx", True) End But i was using a button with javascript ALERT and recently changed to Jquery UI Model dialog but it doesn't wait for me to answer the question.. the postback happenes immediatly ... so i decided to change to a standard HTML button ... but i need to postback to the asp.net page and call a method like. If i just postback it won't call the cleanup Protected Sub Cleanup() UtilTMP.DisposeObjects() Server.Transfer("~\Forms\test.aspx", True) End

    Read the article

  • Most popular compiler?

    - by Russel
    Hello, I've been using MS Visual Studio for a lot of projects, but I notice a lot of people here like to complain about Microsoft and Visual Studio. So I'm wondering, what does everyone use? Dev-C++? mingw? What is popular? Also, what is bad about MSVS? What is "better" about the others? Thanks! --RKL

    Read the article

  • Transfer From a Wordpress Blog to Direct domain

    - by Jaco
    One of my friends is facing an issue. He have a blog with wordpress - 'www.xyz.wordpress.com' and he want to convert it to 'www.xyz.com' by purchasing a domain name with wordpress. In this case, what would happen to his existing RSS feeds once the blog is transferred from www.xyz.wordpress.com to www.xyz.com. Will the RSS Subscribers be automatically upgraded? He have not burnt my feeds using FeedBurner.

    Read the article

  • Issue with .cab file (ActiveX) installation on Windows Vista and 7

    - by Ummar
    I have made an ActiveX control and have made its .cab file for automatic installation on client machine using Internet Explorer.. It working fine of Windows XP, but on windows Vista and Windows 7 its installation is blocked by UAC (User account control), and when I disable it, all things works fine... I have signed my .cab file with a certificate for development enviornment... What is the way to over come this problem.. I don't want to tell users to disable their UAC module...

    Read the article

  • Scripting.dictionary to c#

    - by naresh
    Facing one problem please help me.... We are product development company and our existing application is in ASP, I am trying to send scripting.dictionary object to c#'s com visible class. I am using the System.Collections.Generic class here is my code ASP: dim dictForm set dictForm=CreateObject("scripting.dictionary") dictForm("First") ="one" dictForm("Second") ="two" SET OBJMSGBOX = Server.CreateObject("DictionarySerializer.DictionarySerializer") call OBJMSGBOX.ConvertDictionary(dictForm) c#: [ComVisible(true)] public class DictionarySerializer : IXmlSerializable { Dictionary dict = new Dictionary(); public void ConvertDictionary(Dictionary dictionary) { this.dict = dictionary; } } I am getting error Invalid procedure call or argument: 'ConvertDictionary' Please tell me where I am going in wrong way.

    Read the article

  • rank on two dates - each date iteratively

    - by Abhi
    How to query for rank over 'value' for each day in the below table? Ex: IT should list out the 'mydate', 'value', 'rank' for all values on 20th and then do a fresh rank() for all values on 21st? Thanks... create table tv (mydate,value) as select to_date('20/03/2010 00','dd/mm/yyyy HH24'),98 from dual union all select to_date('20/03/2010 01','dd/mm/yyyy HH24'),124 from dual union all select to_date('20/03/2010 02','dd/mm/yyyy HH24'),140 from dual union all select to_date('20/03/2010 03','dd/mm/yyyy HH24'),138 from dual union all select to_date('20/03/2010 04','dd/mm/yyyy HH24'),416 from dual union all select to_date('20/03/2010 05','dd/mm/yyyy HH24'),196 from dual union all select to_date('20/03/2010 06','dd/mm/yyyy HH24'),246 from dual union all select to_date('20/03/2010 07','dd/mm/yyyy HH24'),176 from dual union all select to_date('20/03/2010 08','dd/mm/yyyy HH24'),124 from dual union all select to_date('20/03/2010 09','dd/mm/yyyy HH24'),128 from dual union all select to_date('20/03/2010 10','dd/mm/yyyy HH24'),32010 from dual union all select to_date('20/03/2010 11','dd/mm/yyyy HH24'),384 from dual union all select to_date('20/03/2010 12','dd/mm/yyyy HH24'),368 from dual union all select to_date('20/03/2010 13','dd/mm/yyyy HH24'),392 from dual union all select to_date('20/03/2010 14','dd/mm/yyyy HH24'),374 from dual union all select to_date('20/03/2010 15','dd/mm/yyyy HH24'),350 from dual union all select to_date('20/03/2010 16','dd/mm/yyyy HH24'),248 from dual union all select to_date('20/03/2010 17','dd/mm/yyyy HH24'),396 from dual union all select to_date('20/03/2010 18','dd/mm/yyyy HH24'),388 from dual union all select to_date('20/03/2010 19','dd/mm/yyyy HH24'),360 from dual union all select to_date('20/03/2010 20','dd/mm/yyyy HH24'),194 from dual union all select to_date('20/03/2010 21','dd/mm/yyyy HH24'),234 from dual union all select to_date('20/03/2010 22','dd/mm/yyyy HH24'),328 from dual union all select to_date('20/03/2010 23','dd/mm/yyyy HH24'),216 from dual union all select to_date('21/03/10 00','dd/mm/yyyy HH24'),224 from dual union all select to_date('21/03/10 01','dd/mm/yyyy HH24'),292 from dual union all select to_date('21/03/10 02','dd/mm/yyyy HH24'),264 from dual union all select to_date('21/03/10 03','dd/mm/yyyy HH24'),132 from dual union all select to_date('21/03/10 04','dd/mm/yyyy HH24'),142 from dual union all select to_date('21/03/10 05','dd/mm/yyyy HH24'),328 from dual union all select to_date('21/03/10 06','dd/mm/yyyy HH24'),184 from dual union all select to_date('21/03/10 07','dd/mm/yyyy HH24'),240 from dual union all select to_date('21/03/10 08','dd/mm/yyyy HH24'),224 from dual union all select to_date('21/03/10 09','dd/mm/yyyy HH24'),496 from dual union all select to_date('21/03/10 10','dd/mm/yyyy HH24'),370 from dual union all select to_date('21/03/10 11','dd/mm/yyyy HH24'),352 from dual union all select to_date('21/03/10 12','dd/mm/yyyy HH24'),438 from dual union all select to_date('21/03/10 13','dd/mm/yyyy HH24'),446 from dual union all select to_date('21/03/10 14','dd/mm/yyyy HH24'),426 from dual union all select to_date('21/03/10 15','dd/mm/yyyy HH24'),546 from dual union all select to_date('21/03/10 16','dd/mm/yyyy HH24'),546 from dual union all select to_date('21/03/10 17','dd/mm/yyyy HH24'),684 from dual union all select to_date('21/03/10 18','dd/mm/yyyy HH24'),568 from dual union all select to_date('21/03/10 19','dd/mm/yyyy HH24'),504 from dual union all select to_date('21/03/10 20','dd/mm/yyyy HH24'),392 from dual union all select to_date('21/03/10 21','dd/mm/yyyy HH24'),256 from dual union all select to_date('21/03/10 22','dd/mm/yyyy HH24'),236 from dual union all select to_date('21/03/10 23','dd/mm/yyyy HH24'),168 from dual

    Read the article

  • CGContextSetShadow() - shadow direction reversed between iOS 3.0 and 4.0?

    - by Pascal
    I've been using CGContextSetShadowWithColor() in my Quartz drawing code on the iPhone to generate the "stomped in" look for text and other things (in drawRect: and drawLayer:inContext:). Worked perfectly, but when running the exact same code against iOS 3.2 and now iOS 4.0 I noticed that the shadows are all in the opposite direction. E.g. in the following code I set a black shadow to be 1 pixel above the text, which gave it a "pressed in" look, and now this shadow is 1px below the text, giving it a standard shadow. ... CGContextSetShadowWithColor(context, CGSizeMake(0.f, 1.f), 0.5f, shadowColor); CGContextShowGlyphsAtPoint(context, origin.x, origin.y, glyphs, length); ... Now I don't know whether I am (or have been) doing something wrong or whether there has been a change to the handling of this setting. I haven't applied any transformation that would explain this to me, at least not knowingly. I've flipped the text matrix in one instance, but not in others and this behavior is consistent. Plus I wasn't able to find anything about this in the SDK Release Notes, so it looks like it's probably me. What might be the issue?

    Read the article

  • Newb Question: scanf() in C

    - by riemannliness
    So I started learning C today, and as an exercise i was told to write a program that asks the user for numbers until they type a 0, then adds the even ones and the odd ones together. Here is is (don't laugh at my bad style): #include <stdio.h>; int main() { int esum = 0, osum = 0; int n, mod; puts("Please enter some numbers, 0 to terminate:"); scanf("%d", &n); while (n != 0) { mod = n % 2; switch(mod) { case 0: esum += n; break; case 1: osum += n; } scanf("%d", &n); } printf("The sum of evens:%d,\t The sum of odds:%d", esum, osum); return 0; } My question concerns the mechanics of the scanf() function. It seems that when you enter several numbers at once separated by spaces (eg. 1 22 34 2 8), the scanf() function somehow remembers each distinct numbers in the line, and steps through the while loop for each one respectively. Why/how does this happen? Example interaction within command prompt: - Please enter some numbers, 0 to terminate: 42 8 77 23 11 (enter) 0 (enter) - The sum of evens:50, The sum of odds:111 I'm running the program through the command prompt, it's compiled for win32 platforms with visual studio.

    Read the article

  • List of Django model instance foreign keys losing consistency during state changes.

    - by Joshua
    I have model, Match, with two foreign keys: class Match(model.Model): winner = models.ForeignKey(Player) loser = models.ForeignKey(Player) When I loop over Match I find that each model instance uses a unique object for the foreign key. This ends up biting me because it introduces inconsistency, here is an example: >>> def print_elo(match_list): ... for match in match_list: ... print match.winner.id, match.winner.elo ... print match.loser.id, match.loser.elo ... >>> print_elo(teacher_match_list) 4 1192.0000000000 2 1192.0000000000 5 1208.0000000000 2 1192.0000000000 5 1208.0000000000 4 1192.0000000000 >>> teacher_match_list[0].winner.elo = 3000 >>> print_elo(teacher_match_list) 4 3000 # Object 4 2 1192.0000000000 5 1208.0000000000 2 1192.0000000000 5 1208.0000000000 4 1192.0000000000 # Object 4 >>> I solved this problem like so: def unify_refrences(match_list): """Makes each unique refrence to a model instance non-unique. In cases where multiple model instances are being used django creates a new object for each model instance, even if it that means creating the same instance twice. If one of these objects has its state changed any other object refrencing the same model instance will not be updated. This method ensure that state changes are seen. It makes sure that variables which hold objects pointing to the same model all hold the same object. Visually this means that a list of [var1, var2] whose internals look like so: var1 --> object1 --> model1 var2 --> object2 --> model1 Will result in the internals being changed so that: var1 --> object1 --> model1 var2 ------^ """ match_dict = {} for match in match_list: try: match.winner = match_dict[match.winner.id] except KeyError: match_dict[match.winner.id] = match.winner try: match.loser = match_dict[match.loser.id] except KeyError: match_dict[match.loser.id] = match.loser My question: Is there a way to solve the problem more elegantly through the use of QuerySets without needing to call save at any point? If not, I'd like to make the solution more generic: how can you get a list of the foreign keys on a model instance or do you have a better generic solution to my problem? Please correct me if you think I don't understand why this is happening.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >