Search Results

Search found 7127 results on 286 pages for 'calculated columns'.

Page 43/286 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • Rails activerecord includes. How to access the included columns?

    - by Lee Quarella
    I my User has_many :event_patrons and EventPatron belongs_to :user. I would like to slap together the user with one specific event patron with something like this sql statement: SELECT * FROM `users` INNER JOIN `event_patrons` ON `event_patrons`.`user_id` = `users`.`id` WHERE `event_patrons`.`event_id` = 1 So in rails I tried this: User.all(:joins => :event_patrons, :condidions => {:event_patrons => {:event_id => 1}}) But that gives me SELECT users.* instead of SELECT *: SELECT `users`* FROM `users` INNER JOIN `event_patrons` ON `event_patrons`.`user_id` = `users`.`id` WHERE `event_patrons`.`event_id` = 1 I then tried to switch the :joins with :include and got a whole jumbled mess that still returned me only the columns in User and none from EventPatron. What am I missing?

    Read the article

  • Looking for an example of selecting a row(s) with multiple columns from a grid view and add them to

    Here is the situation dealing with a vb.net website, I have students who will be enrolled into a course. The student grid view has many columns like client_no, student_name, date_of_birth, address, etc. There are over 100000 students so I will need to filter the student grid view to find the correct student to enroll in the course. Once they are found, the user selects them and somehow moves them to the enrolled grid view. If a student drops out then they would be removed from the enrolled grid view. This process needs to be easy to understand and use. Are there any examples available or other suggestions on how to do this?

    Read the article

  • Can MySQL automatically specify `_utf8` for inserts to UTF-8 columns?

    - by Neil
    I have a table like this, where one column is latin1, the other is UTF-8: Create Table: CREATE TABLE `names` ( `name_english` varchar(255) character NOT NULL, `name_chinese` varchar(255) character set utf8 default NULL, ) ENGINE=MyISAM DEFAULT CHARSET=latin1 When I do an insert, I have to type _utf8 before values being inserted into UTF-8 columns: insert into names (name_english = "hooey", name_chinese = _utf8 "??"); However, since MySQL should know that name_chinese is a UTF-8 column, it should be able to know to use _utf8 automatically. Is there any way to tell MySQL to use _utf8 automatically, so when I'm programatically making prepared statements, I don't have to worry about including it with the right parameters?

    Read the article

  • How to extract certain columns from a big Notepad text file?

    - by user560464
    I have a big text file and the data in it are in 5 columns, but I need just the first and the last column of that. It will take many days and probably with mistake if I want to enter the data of this two column one-by-one from here to another file. Is there a fast way to do this? For example: 1 1.0000000000000000 0.0000000000 S {0} 2 1.5000000000000000 0.3010299957 C {2} 3 1.7500000000000000 0.6020599913 S {0,2} 4 2.0000000000000000 0.7781512504 C {3} 5 2.3333333333333333 1.0791812460 C {3,2} 6 2.5000000000000000 1.3802112417 S {3,0,2} 7 2.5277777777777778 1.5563025008 S {0,3} 8 2.5833333333333333 1.6812412374 S {3,0,0,2} 9 2.8000000000000000 1.7781512504 C {5,2} 10 3.0000000000000000 2.0791812460 C {5,0,2} I need the first column (numbering) and the last inside { }.

    Read the article

  • How can we copy the column data of one datatable to another,even if there is different column names

    - by Harikrishna
    I have two datatables. First is DataTable NameAdressPhones = new DataTable(); with Three columns Name,Adress and PhoneNo.But I want only two columns Name and Adress data so I am copy those columns (with data) to the new datatable DataTable NameAdress = new DataTable(); For that I do foreach (DataRow sourcerow in NameAdressPhones.Rows) { DataRow destRow = NameAdress.NewRow(); foreach (string colname in columns) { destRow[colname] = sourcerow[colname]; } NameAdress.Rows.Add(destRow); } Now I clear every time the NameAdressPhones(first) datatable when there are new records in the table.And every time there will be same no of columns but column name will be different like Nm instead of Name,Add instead of Address.Now problem is second datatable have already column names Name and Address and now I want to copy the columns data of Nm and Add to the second datatabel but the column names are different to the second datatable.So even If there is different column names I want to copy Nm column data of first datatable to the column Name of second datatable and column Add data of first datatable to column Address of second datatable.

    Read the article

  • uninitialized constant Active Scaffold rails 2.3.5

    - by Kiva
    Hi guy, I update my rails application 2.0.2 to 2.3.5. I use active scaffold for the administration part. I change nothing in my code but a problem is coming with the update. I have a controller 'admin/user_controller' to manage users. Here is the code of the controller: class Admin::UserController < ApplicationController layout 'admin' active_scaffold :user do |config| config.columns.exclude :content, :historique_content, :user_has_objet, :user_has_arme, :user_has_entrainement, :user_has_mission, :mp, :pvp, :user_salt, :tchat, :notoriete_by_pvp, :invitation config.list.columns = [:user_login, :user_niveau, :user_mail, :user_bloc, :user_valide, :group_id] #:user_description, :race, :group, :user_lastvisited, :user_nextaction, :user_combats_gagner, :user_combats_perdu, :user_combats_nul, :user_password, :user_salt, :user_combats, :user_experience, :user_mana, :user_vie config.create.link.page = true config.update.link.page = true config.create.columns.add :password, :password_confirmation config.update.columns.add :password, :password_confirmation config.create.columns.exclude :user_password, :user_salt config.update.columns.exclude :user_password, :user_salt config.list.sorting = {:user_login => 'ASC'} config.subform.columns = [] end end This code hasn't change with the update, but when I go in this page, I got this error: uninitialized constant Users /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in `constantize' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:28:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:11:in `reverse' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb:117:in `autolink?' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:107:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:106:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:59:in `active_scaffold' /Users/Kiva/Documents/Projet-rpg/jeu/app/controllers/admin/user_controller.rb:11 I search since 2 days but I don't find the problem, can you help me please.

    Read the article

  • fill gridview cell-by-cell

    - by raging_boner
    I want to populate GridView below with images: <asp:GridView ID="GrdDynamic" runat="server" AutoGenerateColumns="False"> <Columns> </Columns> </asp:GridView> The code below iterates through directory, then I collect image titles and want them to be populated in gridview. code in bold is not working well, gridview is only filled with the last image in list. List<string> imagelist = new List<string>(); protected void Page_Load(object sender, EventArgs e) { foreach (String image in Directory.GetFiles(Server.MapPath("example/"))) { imagelist.Add("~/example/" + Path.GetFileName(image)); } loadDynamicGrid(imagelist); } private void loadDynamicGrid(List<string> list) { DataTable dt = new DataTable(); DataColumn dcol = new DataColumn(NAME, typeof(System.String)); dt.Columns.Add(dcol); dcol = new DataColumn("NAME1", typeof(System.String)); dt.Columns.Add(dcol); dcol = new DataColumn("NAME2", typeof(System.String)); dt.Columns.Add(dcol); dcol = new DataColumn("NAME3", typeof(System.String)); dt.Columns.Add(dcol); DataRow drow = dt.NewRow(); dt.Rows.Add(); dt.Rows.Add(); **for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { foreach (string value in list) { dt.Rows[i][j] = value; } } }** foreach (DataColumn col in dt.Columns) { ImageField bfield = new ImageField(); bfield.DataImageUrlField = NAME; bfield.HeaderText = col.ColumnName; GrdDynamic.Columns.Add(bfield); } GrdDynamic.DataSource = dt; GrdDynamic.DataBind(); } how to fill gridview cell-by-cell only with available amount of images? i know it is easy, i tried various methods like: dt.Rows.Add(list); and some other attempts, but they didn't work. i'm very stupid. i'd be glad for any help.

    Read the article

  • uninitialized constant Active Scaffold rails 2.3.5

    - by Kiva
    Hi guy, I update my rails application 2.0.2 to 2.3.5. I use active scaffold for the administration part. I change nothing in my code but a problem is coming with the update. I have a controller 'admin/user_controller' to manage users. Here is the code of the controller: class Admin::UserController < ApplicationController layout 'admin' active_scaffold :user do |config| config.columns.exclude :content, :historique_content, :user_has_objet, :user_has_arme, :user_has_entrainement, :user_has_mission, :mp, :pvp, :user_salt, :tchat, :notoriete_by_pvp, :invitation config.list.columns = [:user_login, :user_niveau, :user_mail, :user_bloc, :user_valide, :group_id] #:user_description, :race, :group, :user_lastvisited, :user_nextaction, :user_combats_gagner, :user_combats_perdu, :user_combats_nul, :user_password, :user_salt, :user_combats, :user_experience, :user_mana, :user_vie config.create.link.page = true config.update.link.page = true config.create.columns.add :password, :password_confirmation config.update.columns.add :password, :password_confirmation config.create.columns.exclude :user_password, :user_salt config.update.columns.exclude :user_password, :user_salt config.list.sorting = {:user_login => 'ASC'} config.subform.columns = [] end end This code hasn't change with the update, but when I go in this page, I got this error: uninitialized constant Users /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in `constantize' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:28:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:11:in `reverse' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb:117:in `autolink?' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:107:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:106:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:59:in `active_scaffold' /Users/Kiva/Documents/Projet-rpg/jeu/app/controllers/admin/user_controller.rb:11 I search since 2 days but I don't find the problem, can you help me please.

    Read the article

  • Evenly distribute items on the screen

    - by abolotnov
    I am trying to solve this little puzzle (the algorithm): I have N image icons and I want to distribute them evenly on users screen. Say, I put them in a table. If there is one image, there will be one cell in a table. If two - one row with two columns, if three - one row and three columns, if four - two rows, two columns... and so on until row space is gone and since then the table should only grow in columns without adding extra rows. I'm trying to figure an algorithm for this and perhaps this is something that has a solution already somewhere? My attempt is so far something like this: obtain_max_rows() obtain_visible_columns() if (number_of_pictures > max_rows*max_columns) { columns = roundup(number_of_pictures/max_rows) for(max_rows){generate row;for columns{generate column}} } else { **here comes to trouble...** } This logic is bit silly though - it somehow needs to think cases where there are 12 pictures on first screen and 2 on the other trying to balance it say 8/6 or somehow like that.

    Read the article

  • IE 8 Automatically Closing <header> tag

    - by djthoms
    Background I am currently working on the final QA of a responsive website and I'm having an issue with IE 8 and IE 7. My client deals with government contracting so their website needs to be compatible with IE 8 and IE 7. I am using Modernizr with html5shiv built in. I am loading Modernizr in the footer of a WordPress theme that was custom built for this project. I'm not missing a doctype or any other obvious code. I am using the following scripts, all of which are loaded in the footer of WordPress: jQuery 1.10.1 Modernizr 2.6.3 (click for config) respond.js 1.3.0 superfish jQuery Waypoints 2.0.3 jQuery Waypoints Sticky 2.0.3 The Situation I'm having an issue with IE 8 automatically closing a <header> tag. First, I have used two utilities to check this issue: IETester IE 11 emulated to IE 8 w/ IE 8 User agent Here is the correct output <div class="wrapper main-header"> <header class="container"> <div class="sixteen columns alpha omega"> <div class="eight columns alpha omega logo"> <a href="http://example.com"><img src="http://example.com/wp-content/uploads/2013/10/logo.png" alt="Example"></a> </div> <div class="wrapper main-navigation desktop"> <nav id="nav" class="six columns alpha omega"> ... </nav> <div class="eight columns alpha omega overlay" style="display: none;"> ... </div> <div class="two columns alpha omega menu-ss"> ... </div> </div><!-- .wrapper.main-navigation --> </div><!-- /.sixteen.columns --> </header><!--/header--> </div><!-- /.main-header --> What IE 8 is rendering: <div class="wrapper main-header"> <header class="container"></header> <div class="sixteen columns alpha omega"> <div class="eight columns alpha omega logo"> <a href="http://example.com"><img src="http://example.com/wp-content/uploads/2013/10/logo.png" alt="Example"></a> </div> <div class="wrapper main-navigation desktop"> <nav id="nav" class="six columns alpha omega"> ... </nav> <div class="eight columns alpha omega overlay" style="display: none;"> ... </div> <div class="two columns alpha omega menu-ss"> ... </div> </div><!-- .wrapper.main-navigation --> </div><!-- /.sixteen.columns --> </header><//header><!--/header--> </div><!-- /.main-header --> What I have Tried Loading html5shiv with IE conditional in the <head> Loading Modernizr in the <head> I have looked at these Stackoverflow questions/answers: html 5 tags foorter or header in ie 8 and ie 7 html5 not rendering header tags in ie IE 8 self closing tags automatically Any assistance with this is greatly appreciated! I would really really really like to finish this website over the weekend. I've been banging my head against a wall for the past few hours over this issue. Update Here are some images from browsershack to cut out the emulation. I tested the site virtually with Windows 7 and WIndows XP (IE 8 & IE 7). http://www.browserstack.com/screenshots/0d7c1d6dd22927c20495e67f07afe8934957b4d1

    Read the article

  • Ruby on Rails ActiveScaffold: Showing {{model}} instead of model name?

    - by AnExtremelySmellyPerson
    Hi there, I'm using ActiveScaffold with Ruby on Rails and I'm loving it, however there is one weird thing. Whenever I hit "Edit" or "Create New" in my webapp's ActiveScaffold, it says "Create {{model}}" or "Update {{model}}" in the webapp rather than using the model's name. Why is this? I have an ads_controller.rb that includes this: active_scaffold :ad do |config| config.label = "Ads" config.columns = [:name, :description, :imageUrl, :linkUrl, :apps, :created_at, :updated_at] config.update.columns = [:name, :description, :imageUrl, :linkUrl, :apps] config.create.columns = config.update.columns list.sorting = {:created_at => 'DESC'} columns[:imageUrl].label = "Image URL" columns[:linkUrl].label = "Link URL" end And my routes.rb includes this: map.namespace :admin do |admin| admin.root :controller => 'admin_home', :action => 'index' admin.resources :ads, :active_scaffold => true end Any thoughts on why I'm seeing "Create {{model}}" instead of "Create ad" ?

    Read the article

  • CSS+HTML: tds are overlapping

    - by Budda
    On my web-site http://vfm-elita.com (it is not in English, sorry for that) - center and right columns are overlapping, please see screenshot for details: Between left and center columns you can see a "gap" with a green background - it is expected and good. But there are no any gap between center and right columns, instead they are overlapping. Issue exists in all known browsers There are no special formatting applied to columns. They are usual 'TD' columns, the only CSS modifier is width that is "250px" for left and right columns, and for center - it is "auto". Please advise how can I correct that error. Thanks a lot!

    Read the article

  • How can I use a delimiter in wmic output, separating columns?

    - by Abhishek Simon
    I want to fetch Windows Hotfix listing with some format, whose output can be separated with some delimiter. so far I found a wmic command which gives me a desired output but the problem is the \s delimiter is not going to work here. Is there a way I can place some , or anyother character, which I can later use in java program to get individual columns? Command wmic qfe get caption,csname,description,hotfixid,installedby,installedon Output Caption CSName Description HotFixID InstalledBy InstalledOn http://go.microsoft.com/fwlink/?LinkId=161784 Abhishek Update KB971033 NT AUTHORITY\SYSTEM 3/15/2012 http://support.microsoft.com/?kbid=2032276 Abhishek Security Update KB2032276 NT AUTHORITY\SYSTEM 3/15/2012 .. . Update I am trying for /f "tokens=1,2,3,4,5,6,7,8,9,10,11" %g in ('wmic qfe get caption,csname,description,fixcomments,hotfixid,installdate,installedby,installedon,name,servicepackineffect,status') do @echo %g,%h,%i,%j,%k,%l,%m,%n,%o,%p but it gives me invalid GET Expression C:\Users\Abhishek\Desktop>for /f "tokens=1,2,3,4,5,6,7,8,9,10,11" %g in ('wmic qfe get caption,csname,description,fixcomments,hotfixid,installdate,installedby,installedon,name,servicepackineffect,status') do @echo %g,%h,%i,%j,%k,%l,%m,%n,%o,%p Invalid GET Expression. What is the problem here? This might solve the problem for me . More Update I even tried the below command but this too does not solve space problem Command for /f "tokens=1,2,3,4,5,6,7,8,9,10,11" %g in ('wmic qfe list') do @echo %g,%h,%i,%j,%k,%l,%m,%n,%o,%p Output Caption,CSName,Description,FixComments,HotFixID,InstallDate,InstalledBy,InstalledOn,Name,ServicePackInEffect http://go.microsoft.com/fwlink/?LinkId=161784,Abhishek,Update,KB971033,NT,AUTHOR,,Y\SYSTEM,3/15/2012, http://support.microsoft.com/?kbid=2281679,Abhishek,Security,Update,KB2281679,NT,AUTHORITY\SYSTEM,3/15/2012, http://support.microsoft.com/?kbid=2284742,Abhishek,Update,KB2284742,NT,AUTHORIT,,SYSTEM,3/15/2012, http://support.microsoft.com/?kbid=2286198,Abhishek,Security,Update,KB2286198,NT,AUTHORITY\SYSTEM,3/15/2012,

    Read the article

  • SQL Server, how to join a table in a "rotated" format (returning columns instead of rows)?

    - by Joshua Carmody
    Sorry for the lame title, my descriptive skills are poor today. In a nutshell, I have a query similar to the following: SELECT P.LAST_NAME, P.FIRST_NAME, D.DEMO_GROUP FROM PERSON P JOIN PERSON_DEMOGRAPHIC PD ON PD.PERSON_ID = P.PERSON_ID JOIN DEMOGRAPHIC D ON D.DEMOGRAPHIC_ID = PD.DEMOGRAPHIC_ID This returns output like this: LAST_NAME FIRST_NAME DEMO_GROUP --------------------------------------------- Johnson Bob Male Smith Jane Female Smith Jane Teacher Beeblebrox Zaphod Male Beeblebrox Zaphod Alien Beeblebrox Zaphid Politician I would prefer the output be similar to the following: LAST_NAME FIRST_NAME Male Female Teacher Alien Politician --------------------------------------------------------------------------------------------------------- Johnson Bob 1 0 0 0 0 Smith Jane 0 1 1 0 0 Beeblebrox Zaphod 1 0 0 1 1 The number of rows in the DEMOGRAPHIC table varies, so I can't say with certainty how many columns I need. The query needs to be flexible. Yes, it would be trivial to do this in code. But this query is one piece of a complicated set of stored procedures, views, and reporting services, many of which are outside my sphere of influence. I need to produce this output inside the database to avoid breaking the system. Any ideas? This is MS SQL Server 2005, by the way. Thanks.

    Read the article

  • How can I line up columns with Perl's printf when the value might be a number or a string?

    - by user317203
    I am trying to output a document that looks like this (more at http://pastebin.com/dpBAY8Sb): 10.1.1.1 100 <unknown> <unknown> <unknown> <unknown> <unknown> 72.12.148.186 94 Canada Hamilton ON 43.250000 -79.833300 0.00 72.68.209.149 24 United States Richmond Hill NY 40.700500 -73.834500 611.32 72.192.33.34 4 United States Rocky Hill CT 41.657800 -72.662700 657.48 I cannot find how to format the output I have to have a floating poing and format the distance between columns. My current code looks something like this. if (defined $longitude){ printf FILE ("%-8s %.6f","",$longitude); }else{ $longitude = "<unknown>"; printf FILE ("%-20s ",$longitude); } The extra "" throws off the whole column and it looks like this (more at http://pastebin.com/kcwHyNwb). 10.1.1.1 100 <unknown> <unknown> <unknown> <unknown> <unknown> 72.12.148.186 94 Canada Hamilton ON 43.250000 -79.833300 0.00 72.68.209.149 24 United States Richmond Hill NY 40.700500 -73.834500 571.06

    Read the article

  • Why are my Fluent NHibernate SubClass Mappings generating redundant columns?

    - by Brook
    I'm using Fluent NHibernate 1.x build 694, built against NH 3.0 I have the following entities public abstract class Card { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } public virtual Product Product { get; set; } public virtual Sprint Sprint { get; set; } } public class Story:Card { public virtual double Points { get; set; } public virtual int Priority { get; set; } public virtual IList<Task> Tasks { get; set; } } And the following mappings public class CardMap:ClassMap<Card> { public CardMap() { Id(c => c.Id) .Index("Card_Id"); Map(c => c.Name) .Length(50) .Not.Nullable(); Map(c => c.Description) .Length(1024) .Not.Nullable(); References(c=>c.Product) .Not.Nullable(); References(c=>c.Sprint) .Nullable(); } } public class StoryMap : SubclassMap<Story> { public StoryMap() { Map(s => s.Points); Map(s => s.Priority); HasMany(s => s.Tasks); } } When I generate my Schema, the tables are created as follows Card --------- Id Name Description Product_id Sprint_id Story ------------ Card_id Points Priority Product_id Sprint_id What I would have expected would have been to see the columns Product_id and Sprint_id ONLY in the Card table, not the Story table. What am I doing wrong or misunderstanding?

    Read the article

  • Best way to randomly select columns from random rows of SQL results.

    - by LesterDove
    A search of SO yields many results describing how to select random rows of data from a database table. My requirement is a bit different, though, in that I'd like to select individual columns from across random rows in the most efficient/random/interesting way possible. To better illustrate: I have a large Customers table, and from that I'd like to generate a bunch of fictitious demo Customer records that aren't real people. I'm thinking of just querying randomly from the Customers table, and then randomly pairing FirstNames with LastNames, Address, City, State, etc. So if this is my real Customer data (simplified): FirstName LastName State ========================== Sally Simpson SD Will Warren WI Mike Malone MN Kelly Kline KS Then I'd generate several records that look like this: FirstName LastName State ========================== Sally Warren MN Kelly Malone SD Etc. My initial approach works, but it lacks the elegance that I'm hoping the final answer will provide. (I'm particularly unhappy with the repetitiveness of the subqueries, and the fact that this solution requires a known/fixed number of fields and therefore isn't reusable.) SELECT FirstName = (SELECT TOP 1 FirstName FROM Customer ORDER BY newid()), LastName= (SELECT TOP 1 LastNameFROM Customer ORDER BY newid()), State = (SELECT TOP 1 State FROM Customer ORDER BY newid()) Thanks!

    Read the article

  • Is it bad use "display: table;" to organise a layout into 2 columns?

    - by Colen
    Hello, I am trying to make a 2 column layout, apparently the bane of CSS. I know you shouldn't use tables for layout, but I've settled on this CSS. Note the use of display: table etc. div.container { width: 600px; height: 300px; margin: auto; display: table; table-layout: fixed; } ul { white-space: nowrap; overflow: hidden; display: table-cell; width: 40%; } div.inner { display: table-cell; width: auto; } With this layout: <div class="container"> <ul> <li>First</li> <li>Second</li> <li>Third</li> </ul> <div class="inner"> <p>Hello world</p> </div> </div> This seems to work admirably. However, I can't help wondering - am I obeying the letter of the "don't use tables" rule, but not the spirit? I think it's ok, since there's no positioning markup in the HTML code, but I'm just not sure about the "right" way to do it. I can't use css float, because I want the columns to expand and contract with the available space. Please, stack overflow, help me resolve my existential sense of dread at these pseudo-tables.

    Read the article

  • How do I tweak columns in a Flat File Destination in SSIS?

    - by theog
    I have an OLE DB Data source and a Flat File Destination in the Data Flow of my SSIS Project. The goal is simply to pump data into a text file, and it does that. Where I'm having problems is with the formatting. I need to be able to rtrim() a couple of columns to remove trailing spaces, and I have a couple more that need their leading zeros preserved. The current process is losing all the leading zeros. The rtrim() can be done by simple truncation and ignoring the truncation errors, but that's very inelegant and error prone. I'd like to find a better way, like actually doing the rtrim() function where needed. Exploring similar SSIS questions & answers on SO, the thing to do seems to be "Use a Script Task", but that's ususally just thrown out there with no details, and it's not at all an intuitive thing to set up. I don't see how to use scripting to do what I need. Do I use a Script Task on the Control Flow, or a Script Component in the Data Flow? Can I do rtrim() and pad strings where needed in a script? Anybody got an example of doing this or similar things? Many thanks in advance.

    Read the article

  • how can i set up a uniqueness constraint in mysql for columns that can be null?

    - by user299689
    I know that in MySQL, UNIQUE constraits don't treat NULL values as equal. So if I have a unique constraint on ColumnX, then two separate rows can have values of NULL for ColumnX and this wouldn't violate the constraint. How can I work around this? I can't just set the value to an arbitrary constant that I can flag, because ColumnX in my case is actually a foreign key to another table. What are my options here? Please note that this table also has an "id" column that is its primary key. Since I'm using Ruby on Rails, it's important to keep this id column as the primary key. Note 2: In reality, my unique key encompasses many columns, and some of them have to be null, because they are foreign keys, and only one of them should be non-null. What I'm actually trying to do is to "simulate" a polymorphic relationship in a way that keep referential integrity in the db, but using the technique outlined in the first part of the question asked here: http://stackoverflow.com/questions/922184/why-can-you-not-have-a-foreign-key-in-a-polymorphic-association

    Read the article

  • Performance of stored proc when updating columns selectively based on parameters?

    - by kprobst
    I'm trying to figure out if this is relatively well-performing T-SQL (this is SQL Server 2008). I need to create a stored procedure that updates a table. The proc accepts as many parameters as there are columns in the table, and with the exception of the PK column, they all default to NULL. The body of the procedure looks like this: CREATE PROCEDURE proc_repo_update @object_id bigint ,@object_name varchar(50) = NULL ,@object_type char(2) = NULL ,@object_weight int = NULL ,@owner_id int = NULL -- ...etc AS BEGIN update object_repo set object_name = ISNULL(@object_name, object_name) ,object_type = ISNULL(@object_type, object_type) ,object_weight = ISNULL(@object_weight, object_weight) ,owner_id = ISNULL(@owner_id, owner_id) -- ...etc where object_id = @object_id return @@ROWCOUNT END So basically: Update a column only if its corresponding parameter was provided, and leave the rest alone. This works well enough, but as the ISNULL call will return the value of the column if the received parameter was null, will SQL Server optimize this somehow? This might be a performance bottleneck on the application where the table might be updated heavily (insertion will be uncommon so the performance there is not a problem). So I'm trying to figure out what's the best way to do this. Is there a way to condition the column expressions with something like CASE WHEN or something? The table will be indexed up the wazoo as well for read performance. Is this the best approach? My alternative at this point is to create the UPDATE expression in code (e.g. inline SQL) and execute it against the server. This would solve my doubts about performance, but I'd rather leave this in a stored proc if possible.

    Read the article

  • DataTables - Total rowCount - How to cut euro sign in the columns?

    - by Ivan M
    For my DataTable I'm using the fnFooterCallback function to display the total amount of the column, which is working untill the columns contain a special character, like in this case a euro valuta sign. How can I adjust this code so it will not detect the euro sign? "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { /* * Calculate the total market share for all browsers in this table (ie inc. outside * the pagination) */ var iTotal = 0; for ( var i=0 ; i<aaData.length ; i++ ) { iTotal += aaData[i][7]*1; } /* Calculate the market share for browsers on this page */ var iPage = 0; for ( var i=iStart ; i<iEnd ; i++ ) { iPage += aaData[ aiDisplay[i] ][7]*1; } /* Modify the footer row to match what we want */ var nCells = nRow.getElementsByTagName('th'); nCells[1].innerHTML = parseInt(iPage); } Thank you in advance. EDIT With not detecting I mean to str_replace or something like that. Not familiar with javascript language..

    Read the article

  • Matching up text in 2 different columns in a table?

    - by user297663
    Hey guys, I have recently been working on a pastebin script (for fun) and I've come across a problem that I can't seem to solve in CSS. I have a table with 2 columns. 1 column is used to display the line numbers and the 2nd column is used to display the code. I can't seem to get the numbers match up with the lines in the code so it looks all weird (example: www.zamnproductions.com/paste.php?id=32). Take a look at my code (the snippet): <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> td.num { vertical-align: top; } td.numbers { display:table-cell; padding:1px; vertical-align: top; line-height:25px; } td.code { display:table-cell; vertical-align: top; line-height:20px; } #hide { display:none; } #leftcontent { position: absolute; left:10px; top:119px; width:200px; background:#fff; border:0px solid #000; } #centercontent { background:#fff; margin-left: 199px; margin-right:199px; border:0px solid #000; voice-family: "\"}\""; voice-family: inherit; margin-left: 201px; margin-right:201px; } htmlbody #centercontent { margin-left: 202px; margin-right:201px; } Here is the part where the table is made: listNumbers($_GET['id']); ? viewCode($_GET['id']); ?

    Read the article

  • How to easily change columns into rows in Excel?

    - by DavidD
    I have a huge Excel table that I need to transform into paragraphs for a Word report, and I can't find an efficient way to do it The source looks like this: And I would ultimately need something like this, i.e. through a pivot table. Note that "Item C", which doesn't have any description values, is skipped: Now, to get there I believe I need to transform my source to this intermediate format, that has one description per line: How do I get from the source to the intermediate format in an efficient way? Or maybe there is an easier way to produce the target format that I don't know of? Any help is welcome!

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >