Search Results

Search found 6399 results on 256 pages for 'record'.

Page 25/256 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • How to get record value from LinqDataSource via Code Behind

    - by rockinthesixstring
    I've got a LinqDataSource that retrieves a single record. Protected Sub LinqDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqDataSource1.Selecting Dim BizForSaleDC As New DAL.BizForSaleDataContext e.Result = BizForSaleDC.bt_BizForSale_GetByID(e.WhereParameters("ID")).FirstOrDefault End Sub I'd like to be able to retrieve the values of said DataSource using the Page_Load function. Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load 'Get the right usercontrol' Dim ctrl As UserControl Select Case DataBinder.Eval(LINQDATASOURCE_SOMETHING.DataItem, "AdType") Case 1 : ctrl = DirectCast(Me.FindControl("Default1"), UserControl) Case 2 : ctrl = DirectCast(Me.FindControl("Default1"), UserControl) Case 3 : ctrl = DirectCast(Me.FindControl("ValuPro1"), UserControl) Case 4 : ctrl = DirectCast(Me.FindControl("ValuPro1"), UserControl) Case Else : ctrl = Nothing End Select 'set the control to visible' ctrl.Visible = True End Sub But obviously the code above doesn't work... I'm just wondering if there's a way to make it work. Here is the full markup <body> <form id="form1" runat="server"> <asp:LinqDataSource ID="LinqDataSource1" runat="server"> <WhereParameters> <asp:QueryStringParameter ConvertEmptyStringToNull="true" Name="ID" QueryStringField="ID" Type="Int32" /> </WhereParameters> </asp:LinqDataSource> <uc:Default ID="Default1" runat="server" Visible="false" /> <uc:ValuPro ID="ValuPro1" runat="server" Visible="false" /> </form> </body> </html> Basically what happens is the appropriate usercontrol is enabled and that usercontrol inherits the LinqDataSource and displays the appropriate information. EDIT: It's working now with the code below, however, since I'm really not into hitting the database multiple times for the same info, I'd prefer to get the value from the DataSource. 'Query the database' Dim _ID As Integer = Convert.ToInt32(Request.QueryString("ID")) Dim BizForSaleDC As New BizForSaleDataContext Dim results = BizForSaleDC.bt_BizForSale_GetByID(_ID).FirstOrDefault 'Get the right usercontrol' Dim ctrl As UserControl Select Case results.AdType Case 1 : ctrl = DirectCast(Me.FindControl("Default1"), UserControl) Case 2 : ctrl = DirectCast(Me.FindControl("Default1"), UserControl) Case 3 : ctrl = DirectCast(Me.FindControl("ValuPro1"), UserControl) Case 4 : ctrl = DirectCast(Me.FindControl("ValuPro1"), UserControl) Case Else : ctrl = Nothing End Select

    Read the article

  • Searching Week-wise/Month-wise record counts(number) and the StartDate+EndDate(datetime) of the Week

    - by Muzaffar Ali Rana
    I have a question in connection to this question earlier posted by me:- http://stackoverflow.com/questions/2452984/daily-weekly-monthly-record-count-search-via-storedprocedure I want to have the Count of Calls on Weekly-basis and Monthly-basis, Daily-basis issue is resolved. ISSUE NUMBER @1:Weekly-basis Count of Calls and Start-Date and End-Date of Week I have searched the Start-Date and End-Date of Week including their individual Count of Calls as well in the below-mentioned query. But the problem is that I could not get the result in one single table, although I have used the Temporary Tables(#TempTable+#TempTable2). Kindly help me in this regards. NOTE:Table Creation commented as for executing more than once. ----- *** TABLE CREATION OF #TempTable & #TempTable2 *** ---------- --CREATE TABLE #TempTable( StartDate datetime,EndDate datetime,CallCount numeric(18,5)) --CREATE TABLE #TempTable2( StartDate datetime,EndDate datetime,CallCount numeric(18,5)) DECLARE @StartDate datetime,@EndDate datetime,@StartDateTemp1 datetime,@StartDateTemp2 datetime,@EndDateTemp datetime,@Period varchar(50); SET @StartDate='1/1/2010'; SET @EndDate='2/28/2010'; SET @StartDateTemp1=@StartDate; SET @StartDateTemp2=DATEADD(dd, 7, @StartDate ); SET @Period='Weekly'; IF (@Period = 'Weekly') BEGIN WHILE ((@StartDate <= @StartDateTemp1) AND (@StartDateTemp2 <= @EndDate)) BEGIN IF((@StartDateTemp1 < @StartDateTemp2 ) AND (@StartDateTemp1 != @StartDateTemp2) ) BEGIN SELECT convert(varchar, @StartDateTemp1, 106) AS 'Start Date', convert(varchar, @StartDateTemp2, 106) AS 'End Date', COUNT(*) AS 'Call Count' FROM TRN_Call WHERE (CallTime = @StartDateTemp1 AND CallTime <= @StartDateTemp2 ); END SET @StartDateTemp1 = DATEADD(dd, 7, @StartDateTemp1); SET @StartDateTemp2 = DATEADD(dd, 7, @StartDateTemp2); END END ISSUE NUMBER @2:Monthly-basis Count of Calls and Start-Date and End-Date of Week In this case, I have the same search, but will have to search the Call Counts plus the Start-Date and End-Date of the Month. Kindly help me in this regards as well.

    Read the article

  • record output sound in python

    - by aaronstacy
    i want to programatically record sound coming out of my laptop in python. i found PyAudio and came up with the following program that accomplishes the task: import pyaudio, wave, sys chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 44100 RECORD_SECONDS = 5 WAVE_OUTPUT_FILENAME = sys.argv[1] p = pyaudio.PyAudio() channel_map = (0, 1) stream_info = pyaudio.PaMacCoreStreamInfo( flags = pyaudio.PaMacCoreStreamInfo.paMacCorePlayNice, channel_map = channel_map) stream = p.open(format = FORMAT, rate = RATE, input = True, input_host_api_specific_stream_info = stream_info, channels = CHANNELS) all = [] for i in range(0, RATE / chunk * RECORD_SECONDS): data = stream.read(chunk) all.append(data) stream.close() p.terminate() data = ''.join(all) wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb') wf.setnchannels(CHANNELS) wf.setsampwidth(p.get_sample_size(FORMAT)) wf.setframerate(RATE) wf.writeframes(data) wf.close() the problem is i have to connect the headphone jack to the microphone jack. i tried replacing these lines: input = True, input_host_api_specific_stream_info = stream_info, with these: output = True, output_host_api_specific_stream_info = stream_info, but then i get this error: Traceback (most recent call last): File "./test.py", line 25, in data = stream.read(chunk) File "/Library/Python/2.5/site-packages/pyaudio.py", line 562, in read paCanNotReadFromAnOutputOnlyStream) IOError: [Errno Not input stream] -9975 is there a way to instantiate the PyAudio stream so that it inputs from the computer's output and i don't have to connect the headphone jack to the microphone? is there a better way to go about this? i'd prefer to stick w/ a python app and avoid cocoa.

    Read the article

  • Linq-to-sql Add item and a one-to-many record at once

    - by Oskar Kjellin
    I have a function where I can add articles and users can comment on them. This is done with a one to many relationship like= "commentId=>ArticleId". However when I try to add the comment to the database at the same time as I add the one to many record, the commentId is not known. Like this code: Comment comment = new Comment(); comment.Date = DateTime.UtcNow; comment.Text = text; comment.UserId = userId; db.Comments.InsertOnSubmit(comment); comment.Articles.Add(new CommentsForArticle() { ArticleId = articleId, CommentId = comment.CommentId }); The commentId will be 0 before i press submit. Is there any way arround not having to submit in between or do I simply have to cut out the part where I have a one-to-many relationship and just use a CommentTable with a column like "ArticleId". What is best in a performance perspective? I understand the underlying issue, I just want to know which solution works best.

    Read the article

  • Mailing Address is forcing 2nd Record in CSV (DevExpress Controls)

    - by Gerhard Weiss
    My DevExpress CSV export has two lines per record. Rank Score,Prog.,Full Address 63.30 ,JIW ,1234 Whispering Pines Dr , ,Sometown MI 48316 62.80 ,JIW ,9876 Beagle Dr , ,Sometown Twp MI 48382 I would like to change it to one line because I want to do a Word Merge. (Unless Word can merge these two lines back together, which I do not thing it can do) Does the DevExpress XtraGrid ExportToText allow for this? A MemoEdit is being used by the XtraGrid and is initialized using the following code (Noticed the ControlChars.NewLine): Public ReadOnly Property FullAddress() As String Get Dim strAddress As System.Text.StringBuilder = New StringBuilder() If Not IsNullEntity Then strAddress.Append(Line1 + ControlChars.NewLine) If Not Line2 Is Nothing AndAlso Me.Line2.Length > 0 Then strAddress.Append(Line2 + ControlChars.NewLine) End If If Not Line3 Is Nothing AndAlso Me.Line3.Length > 0 Then strAddress.Append(Line3 + ControlChars.NewLine) End If strAddress.Append(String.Format("{0} {1} {2}", City, RegionCode, PostalCode)) If Me.Country <> "UNITED STATES" Then strAddress.Append(ControlChars.NewLine + Me.Country) End If End If Return strAddress.ToString End Get End Property Here is the export to CSV code: Dim saveFile As New SaveFileDialog With saveFile '.InitialDirectory = ClientManager.CurrentClient.Entity.StudentPictureDirectory .FileName = "ApplicantList.csv" .CheckPathExists = True .CheckFileExists = False .Filter = "All Files (*.*)|*.*" End With If saveFile.ShowDialog() = Windows.Forms.DialogResult.OK Then Dim PrintingTextExportOptions As New DevExpress.XtraPrinting.TextExportOptions(",", Encoding.ASCII) PrintingTextExportOptions.QuoteStringsWithSeparators = True ApplicantRankListViewsGridControl.ExportToText(saveFile.FileName, PrintingTextExportOptions) End If

    Read the article

  • Catching 'Last Record' in Coldfusion for IE javascript bug

    - by Simon Hume
    I'm using ColdFusion to pull UK postcodes into an array for display on a Google Map. This happens dynamically from a SQL database, so the numbers can range from 1 to 100+ the script works great, however, in IE (groan) it decides to display one point way off line, over in California somewhere. I fixed this issue in a previous webapp, this was due to the comma between each array item still being present at the end. Works fine in Firefox, Safari etc, but not IE. But, that one was using a set 10 records, so was easy to fix. I just need a little if statement to wrap around my comma to hide it when it hits the last record. I can't seem to get it right. Any tips/suggestions? here is the line of code in question: var address = [<cfloop query="getApplicant"><cfif getApplicant.dbHomePostCode GT ""><cfoutput>'#getApplicant.dbHomePostCode#',</cfoutput></cfif> </cfloop>]; Hopefully someone can help with this rather simple request. I'm just having a bad day at the office!

    Read the article

  • How to call Postgres function returning SETOF record?

    - by Peter
    I have written the following function: -- Gets stats for all markets CREATE OR REPLACE FUNCTION GetMarketStats ( ) RETURNS SETOF record AS $$ BEGIN SELECT 'R approved offer' AS Metric, SUM(CASE WHEN M.MarketName = 'A+' AND M.Term = 24 THEN LO.Amount ELSE 0 end) AS MarketAPlus24, SUM(CASE WHEN M.MarketName = 'A+' AND M.Term = 36 THEN LO.Amount ELSE 0 end) AS MarketAPlus36, SUM(CASE WHEN M.MarketName = 'A' AND M.Term = 24 THEN LO.Amount ELSE 0 end) AS MarketA24, SUM(CASE WHEN M.MarketName = 'A' AND M.Term = 36 THEN LO.Amount ELSE 0 end) AS MarketA36, SUM(CASE WHEN M.MarketName = 'B' AND M.Term = 24 THEN LO.Amount ELSE 0 end) AS MarketB24, SUM(CASE WHEN M.MarketName = 'B' AND M.Term = 36 THEN LO.Amount ELSE 0 end) AS MarketB36 FROM "Market" M INNER JOIN "Listing" L ON L.MarketID = M.MarketID INNER JOIN "ListingOffer" LO ON L.ListingID = LO.ListingID; END $$ LANGUAGE plpgsql; And when trying to call it like this... select * from GetMarketStats() AS (Metric VARCHAR(50),MarketAPlus24 INT,MarketAPlus36 INT,MarketA24 INT,MarketA36 INT,MarketB24 INT,MarketB36 INT); I get an error: ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function "getmarketstats" line 2 at SQL statement I don't understand this output. I've tried using perform too, but I thought one only had to use that if the function doesn't return anything.

    Read the article

  • Castle Active Record - Working with the cache

    - by David
    Hi All, im new to the Castle Active Record Pattern and Im trying to get my head around how to effectivley use cache. So what im trying to do (or want to do) is when calling the GetAll, find out if I have called it before and check the cache, else load it, but I also want to pass a bool paramter that will force the cache to clear and requery the db. So Im just looking for the final bits. thanks public static List<Model.Resource> GetAll(bool forceReload) { List<Model.Resource> resources = new List<Model.Resource>(); //Request to force reload if (forceReload) { //need to specify to force a reload (how?) XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml"); ActiveRecordStarter.Initialize(source, typeof(Model.Resource)); resources = Model.Resource.FindAll().ToList(); } else { //Check the cache somehow and return the cache? } return resources; } public static List<Model.Resource> GetAll() { return GetAll(false); }

    Read the article

  • Problem with Active Record

    - by kshchepelin
    Hello everyone. Lets assume we have a User model. And user can plan some activities. The number of types of activities is about 50. All activities have common properties, such as start_time, end_time, user_id, etc. But each of them has some unique properties. Now we have each activity living in its own table in DB. And thats why we have such terrible sql queries like SELECT * FROM `first_activities_table` WHERE (`first_activity`.`id` IN (17,18)) SELECT * FROM `second_activities_table` WHERE (`second_activity`.`id` = 17) ..... SELECT * FROM `n_activities_table` WHERE (`n_activity`.`id` = 44) About 50 queries. That's terrible. There are different ways to solve this. Choose the activity type with the biggest number of properties, create the table 'Activities' and have STI model. But this way we must name our columns in uncomfortable way and often the record in that table would have some NULL fields. Also STI model, but having columns, common for all of activity types and some blob column with serialized properties. But we have to do some search on activities - there can be a problem. And serialization is quite slow. Please help me dealing with this. Maybe my problem has quite different solution that will fit my needs. Thanks for help.

    Read the article

  • leaflet/JSONobject. Marker onclick show only last record

    - by user2780898
    that my code <div id='map'></div> <div id="info"></div> [...] var markers1 = new L.MarkerClusterGroup( { showCoverageOnHover: true } ); $.ajax({ type: "GET", url: "db.php", success: function (result) { var JSONobject = JSON.parse(result); var jnCount = JSONobject.length; for (var i = 0; i < jnCount; i++) { var marker = new L.Marker(new L.LatLng(JSONobject[i]["lat"],JSONobject[i]["lng"]),{ icon: myIcon1 }); var id = JSONobject[i]["id"]; var list = "<dl>" + "<dt><b>CITTA':</b> " + JSONobject[i]["citta_"] + "</dt>"; marker.on('click', function() { {document.getElementById('info').innerHTML = list;} }); markers1.addLayer(marker); } map.addLayer(markers1); } }); Marker onclick shows only the last record! I think problem is in loop but I don't understand how fix it. Any idea? Thanks Nicola

    Read the article

  • Access 2007 not allowing user to delete record in subform

    - by Todd McDermid
    Good day... The root of my issue is that there's no context menu allowing the user to delete a row from a form. The "delete" button on the ribbon is also disabled. In Access 2003, apparently this function was available, but since our recent "upgrade" to 2007 (file is still in MDB format) it's no longer there. Please keep in mind I'm not an Access dev, nor did I create this app - I inherited support for it. ;) Now for the details, and what I've tried. The form in question is a subform on a larger form. I've tried turning "AllowDeletes" on on both forms. I've checked the toolbar and ribbon properties on the forms to see if they loaded some custom stuff, but no. I've tried changing the "record locks" to "on edit", no joy. I examined the query to see if it was "too complicated" to permit a delete - as far as I can tell, it's a very simple two (linked) table join. Compared to another form in this app that does permit row deletes, it has a much more complicated (multi-join, built on queries) query. Is there a resource that would describe the required conditions for allowing deletes? Thanks in advance...

    Read the article

  • Atomically maintaining a counter using Sub-sonic ActiveRecord

    - by cantabilesoftware
    I'm trying to figure out the correct way to atomically increment a counter in one table and use that incremented value as an pseudo display-only ID for a record in another. What I have is a companies table and a jobs table. I want each company to have it's own set of job_numbers. I do have an auto increment job_id, but those numbers are shared across all companies. ie: the job numbers should generally increment without gaps for each company. ie: companies(company_id, next_job_number) jobs(company_id, job_id, job_number) Currently I'm doing this (as a method on the partial job class): public void SaveJob() { using (var scope = new System.Transactions.TransactionScope()) { if (job_id == 0) { _db.Update<company>() .SetExpression("next_job_number").EqualTo("next_job_number+1") .Where<company>(x => x.company_id == company_id) .Execute(); company c = _db.companies.SingleOrDefault(x => x.company_id == company_id); job_number = c.next_job_number; } // Save the job this.Save(); scope.Complete(); } } It seems to work, but I'm not sure if there are pitfalls here? It just feels wrong, but I'm not sure how else to do it. Any advice appreciated.

    Read the article

  • Jquery number of clicks record

    - by Maxime
    Hi, I am working on this page where I'm using a Jquery Mp3 Player (Jplayer) with its playlist. What I want to do is very simple in theory: I want to record the number of clicks for every playlist element. When someone enters the page, his number of clicks are at 0 for every element. The visitor can click a few times on element #1, then go to element #2 (which will be at 0), then come back to element #1 and the number of clicks must be saved. We don't need to save it for next visits. Jplayer has this function that loads each time a new playlist element is being loaded: function playListChange( index ) In which every element has its own ID dynamically updated: myPlayList[index].song_id Here's my code: function playListChange( index ) { var id = myPlayList[index].song_id; if(!o) { var o = {}; } if(!o[id]) { o[id] = 0; } alert(o[id]); … $("#mydiv").click { o[id] = o[id]+1; } … But o[id] is reset every time and the alert always show 0. Why? Thanks for any reply.

    Read the article

  • Exception when retrieving record using Nhibernate

    - by Muhammad Akhtar
    I am new to NHibernate and have just started right now. I have very simple table contain Id(Int primary key and auto incremented), Name(varchar(100)), Description(varchar(100)) Here is my XML <class name="DevelopmentStep" table="DevelopmentSteps" lazy="true"> <id name="Id" type="Int32" column="Id"> </id> <property name="Name" column="Name" type="String" length="100" not-null="false"/> <property name="Description" column="Description" type="String" length="100" not-null="false"/> here is how I want to get all the record public List<DevelopmentStep> getDevelopmentSteps() { List<DevelopmentStep> developmentStep; developmentStep = Repository.FindAll<DevelopmentStep>(new OrderBy("Name", Order.Asc)); return developmentStep; } But I am getting exception The element 'id' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping- 2.2:column urn:nhibernate-mapping-2.2:generator'. Please Advise me --- Thanks

    Read the article

  • rails xml to active record object

    - by Brian D.
    I've been googling for a while to try and convert and incoming XML request into an active record object. I've tried using the ActiveRecordObject.new.from_xml method but it doesn't seem to handle relationships. For example, say I have the following xml: <blog> <title></title> <blog-pages> <blog-page> <page-number></page-number> <content></content> </blog-page> </blog-pages> </blog> And I have the following model objects: class Blog < ActiveRecord::Base has_many :blog_pages end class BlogPage < ActiveRecord::Base belongs_to :blog end Is there a way to convert the xml into a blog object WITH relationships? Or do I need to manually parse the XML? Thanks in advance.

    Read the article

  • codeigniter active record and mysql

    - by sea_1987
    I am running a query with Active Record in a modal of my codeigniter application, the query looks like this, public function selectAllJobs() { $this->db->select('*') ->from('job_listing') ->join('job_listing_has_employer_details', 'job_listing_has_employer_details.employer_details_id = job_listing.id', 'left'); //->join('employer_details', 'employer_details.users_id = job_listing_has_employer_details.employer_details_id'); $query = $this->db->get(); return $query->result_array(); } This returns an array that looks like this, [0]=> array(13) { ["id"]=> string(1) "1" ["job_titles_id"]=> string(1) "1" ["location"]=> string(12) "Huddersfield" ["location_postcode"]=> string(7) "HD3 4AG" ["basic_salary"]=> string(19) "£20,000 - £25,000" ["bonus"]=> string(12) "php, html, j" ["benefits"]=> string(11) "Compnay Car" ["key_skills"]=> string(1) "1" ["retrain_position"]=> string(3) "YES" ["summary"]=> string(73) "Lorem Ipsum is simply dummy text of the printing and typesetting industry" ["description"]=> string(73) "Lorem Ipsum is simply dummy text of the printing and typesetting industry" ["job_listing_id"]=> NULL ["employer_details_id"]=> NULL } } The job_listing_id and employer_details_id return as NULL however if I run the SQL in phpmyadmin I get full set of results, the query i running in phpmyadmin is, SELECT * FROM ( `job_listing` ) LEFT JOIN `job_listing_has_employer_details` ON `job_listing_has_employer_details`.`employer_details_id` LIMIT 0 , 30 Is there a reason why I am getting differing results?

    Read the article

  • Can't delete record via the datacontext it was retrieved from

    - by Antilogic
    I just upgraded one of my application's methods to use compiled queries (not sure if this is relevant). Now I'm getting contradicting error messages when I run the code. This is my method: MyClass existing = Queries.MyStaticCompiledQuery(MyRequestScopedDataContext, param1, param2).SingleOrDefault(); if (existing != null) { MyRequestScopedDataContext.MyClasses.DeleteOnSubmit(existing); } When I run it I get this message: Cannot remove an entity that has not been attached. Note that the compiled query and the DeleteOnSubmit reference the same DataContext. Still I figured I'd humor the application and add an attach command before the DeleteOnSubmit, like so: MyClass existing = Queries.MyStaticCompiledQuery(MyRequestScopedDataContext, param1, param2).SingleOrDefault(); if (existing != null) { MyRequestScopedDataContext.MyClasses.Attach(existing); MyRequestScopedDataContext.MyClasses.DeleteOnSubmit(existing); } BUT... When I run this code, I get a completely different contradictory error message: An attempt has been made to Attach or Add an entity that is not new, perhaps having been loaded from another DataContext. This is not supported. I'm at a complete loss... Does anyone else have some insight as to why I can't delete a record via the same DataContext I retrieved it from?

    Read the article

  • How can I record and save flash video's with an H264 codec

    - by JimHendriks
    Right now I am working on an AIR 3.2 application which lets you stream a video to a Flash Media Server and saves it on a hard drive. This sequence works fine with the standard Sorenson codec but I want to use H.264 for my videos. I found lots example c ode and implemented it in my code, but when I record a video of myself I am unable to re-watch it afterwards. I found how to implement a H.264 encoding in a realeyes blog post here. My code is here. It saves the video as a .f4v file, but my browser (I've tried the latest versions of both Chrome and Firefox, with the latest Flash) and also VLC are unable to load the video. I also used a program called Movie Player which is able to open the file but can only show the first frame and the audio. Neither am I able to upload the video to YouTube because they do not support the file extension. Here is an example video file it saved: H264Test1.f4v. My question is: How do I stream and save the movie with a file extension that I am able to re-watch while using the H.264 codec?

    Read the article

  • SQL query for the latest record for each day

    - by Mac
    I've got an Oracle 10g database with a table with a structure and content very similar to the following: CREATE TABLE MyTable ( id INTEGER PRIMARY KEY, otherData VARCHAR2(100), submitted DATE ); INSERT INTO MyTable VALUES (1, 'a', TO_DATE('28/04/2010 05:13', ''DD/MM/YYYY HH24:MI)); INSERT INTO MyTable VALUES (2, 'b', TO_DATE('28/04/2010 03:48', ''DD/MM/YYYY HH24:MI)); INSERT INTO MyTable VALUES (3, 'c', TO_DATE('29/04/2010 05:13', ''DD/MM/YYYY HH24:MI)); INSERT INTO MyTable VALUES (4, 'd', TO_DATE('29/04/2010 17:16', ''DD/MM/YYYY HH24:MI)); INSERT INTO MyTable VALUES (5, 'e', TO_DATE('29/04/2010 08:49', ''DD/MM/YYYY HH24:MI)); What I need to do is query the database for the latest record submitted on each given day. For example, with the above data I would expect the records with ID numbers 1 and 4 to be returned, as these are the latest each for 28 April and 29 April respectively. Unfortunately, I have little expertise as far as SQL is concerned. Could anybody possibly provide some insight as to how to achieve this? Thanks in advance!

    Read the article

  • Cannot locate record in delphi ADO query

    - by Danatela
    I can't locate any record in TADOQuery using PK. First, I was trying to use standard Locate method: PPUQuery.Locate('ID', SpPlansQuery['PPONREC'], []); It always returns False, but manual search (passing the whole query matching ID with given PPONREC which is really slow) finds the desired row. I tried using loPartialKey and switched CursorLocation of query to clUseServer, but it didn't help. Next, I tried to filter my PPUQuery: PPUQuery.Filter := 'ID = ' + VarToStr(SpPlansQuery['PPONREC']); PPUQuery.Filtered := True; PPUQuery.First; But after that the PPUQuery.Eof is True and PPUQuery.RecordCount equals 0. Underlying database is Oracle 9 and the ID is of type INTEGER and is PK of table TPORDER_CMK. PPUQuery.SQL is: SELECT tp.*, la.*, lm.*, ld.*, ld1.*, to_cmk.* FROM ppu_plan.tporder_cmk tp JOIN PPU_PLAN.LARTICLES la ON TP.ARTICLE = LA.ID JOIN PPU_PLAN.LMATERIAL lm ON TP.MATERIAL = lm.id JOIN PPU_PLAN.LCADEP ld ON TP.CADEP = LD.ID JOIN PPU_PLAN.LCADEP ld1 ON TP.PRODUCER = LD1.ID JOIN PPU_PLAN.TORDER_CMK to_cmk ON TP.order_id=TO_cmk.ID WHERE TP.PLAN_ID = :pplan_id What should I try next and how to solve this problem?

    Read the article

  • Rails active record association problem

    - by Harm de Wit
    Hello, I'm new at active record association in rails so i don't know how to solve the following problem: I have a tables called 'meetings' and 'users'. I have correctly associated these two together by making a table 'participants' and set the following association statements: class Meeting < ActiveRecord::Base has_many :participants, :dependent => :destroy has_many :users, :through => :participants and class Participant < ActiveRecord::Base belongs_to :meeting belongs_to :user and the last model class User < ActiveRecord::Base has_many :participants, :dependent => :destroy At this point all is going well and i can access the user values of attending participants of a specific meeting by calling @meeting.users in the normal meetingshow.html.erb view. Now i want to make connections between these participants. Therefore i made a model called 'connections' and created the columns of 'meeting_id', 'user_id' and 'connected_user_id'. So these connections are kinda like friendships within a certain meeting. My question is: How can i set the model associations so i can easily control these connections? I would like to see a solution where i could use @meeting.users.each do |user| user.connections.each do |c| <do something> end end I tried this by changing the model of meetings to this: class Meeting < ActiveRecord::Base has_many :participants, :dependent => :destroy has_many :users, :through => :participants has_many :connections, :dependent => :destroy has_many :participating_user_connections, :through => :connections, :source => :user Please, does anyone have a solution/tip how to solve this the rails way?

    Read the article

  • Simple search only searching last word of record

    - by bennett_an
    I set up a simple search as instructed in part of railscast #240. in controller @reports = Report.search(params[:search]).order('created_at DESC').paginate(:page => params[:page], :per_page => 5) in model def self.search(search) if search where('apparatus LIKE ?', "%#{search}") else scoped end end in view <%= form_tag reports_path, :method => :get do %> <p> <%= text_field_tag :search, params[:search] %> <%= submit_tag "Search", :name => nil %> </p> <% end %> it all works... but... I have a few records for example, one with "another time test" and another with "last test of time" if i search "test" the first comes up but the second doesn't, and if i search "time" the second comes up but not the first. It is only seeing the last word of the record. what gives?

    Read the article

  • Need help INSERT record(s) MySQL DB

    - by JM4
    I have an online form which collects member(s) information and stores it into a very long MySQL database. We allow up to 16 members to enroll at a single time and originally structured the DB to allow such. For example: If 1 Member enrolls, his personal information (first name, last name, address, phone, email) are stored on a single row. If 15 Members enroll (all at once), their personal information are stored in the same single row. The row has information housing columns for all 'possible' inputs. I am trying to consolidate this code and having every nth member that enrolls put onto a new record within the database. I have seen sugestions before for inserting multiple records as such: INSERT INTO tablename VALUES (('$f1name', '$f1address', '$f1phone'), ('$f2name', '$f2address', '$f2phone')... The issue with this is two fold: I do not know how many records are being enrolled from person to person so the only way to make the statement above is to use a loop The information collected from the forms is NOT a single array so I can't loop through one array and have it parse out. My information is collected as individual input fields like such: Member1FirstName, Member1LastName, Member1Phone, Member2Firstname, Member2LastName, Member2Phone... and so on Is it possible to store information in separate rows WITHOUT using a loop (and therefore having to go back and completely restructure my form field names and such (which can't happen due to the way the validation rules are built.)

    Read the article

  • Create rails record from two ids

    - by Michael Luby
    The functionality I'm trying to build allows Users to Visit a Restaurant. I have Users, Locations, and Restaurants models. Locations have many Restaurants. I've created a Visits model with user_id and restaurant_id attributes, and a visits_controller with create and destroy methods. Thing is, I can't create an actual Visit record. Any thoughts on how I can accomplish this? Or am I going about it the wrong way. Here's the code: Model: class Visit < ActiveRecord::Base attr_accessible :restaurant_id, :user_id belongs_to :user belongs_to :restaurant end View: <% @restaurants.each do |restaurant| %> <%= link_to 'Visit', location_restaurant_visits_path(current_user.id, restaurant.id), method: :create %> <% @visit = Visit.find_by_user_id_and_restaurant_id(current_user.id, restaurant.id) %> <%= @visit != nil ? "true" : "false" %> <% end %> Controller: class VisitsController < ApplicationController before_filter :find_restaurant before_filter :find_user def create @visit = Visit.create(params[:user_id => @user.id, :restaurant_id => @restaurant.id]) respond_to do |format| if @visit.save format.html { redirect_to location_restaurants_path(@location), notice: 'Visit created.' } format.json { render json: @visit, status: :created, location: @visit } else format.html { render action: "new" } format.json { render json: @visit.errors, status: :unprocessable_entity } end end end def destroy @visit = Visit.find(params[:user_id => @user.id, :restaurant_id => @restaurant.id]) @restaurant.destroy respond_to do |format| format.html { redirect_to location_restaurants_path(@restaurant.location_id), notice: 'Unvisited.' } format.json { head :no_content } end end private def find_restaurant @restaurant = Restaurant.find(params[:restaurant_id]) end def find_user @user = current_user end end

    Read the article

  • SUM of column with Left Outer Join

    - by Matt
    I am trying to get the Count of all records that have at least on person who is authorized on the record. Basically, a Record can have more than one person associated with it. I want to return the count of Total Records, a count of total Authorized Records where at least 1 person is authorized, and a count of total NotAuthorized records where no person associated with record is authorized. It doesn't matter if one person is authorized per Record or if 3 people are authorized for that record, that should add 1 to the Authorized counter. The current query is incrementing Auth and Non auth for each person added per record rather, than one per record. If no people are assigned to the record that should also count towards Not Auth. SELECT Count(DISTINCT Record.RecordID) AS TotalRecords, SUM(CASE WHEN People.PersonLevel = 1 THEN 1 ELSE 0 END) AS Authorized, SUM(CASE WHEN People.PersonLevel <> 1 THEN 1 ELSE 0 END) AS NotAuthorized FROM Record LEFT OUTER JOIN RecordPeople ON Record.RecordID = RecordPeople.RecordID LEFT OUTER JOIN People ON RecordPeople.PersonID = People.PersonID

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >