VB.NET How to obtain previous record entered from datatable? - mysql

I would like to obtain the last record entered in my database and display it in a textbox.
Here is what I tried
Previous_Project_Float_Detail.Text = projectRecordDT.Rows(projectRecordDT.Rows("FloatNo").Count - 1).ToString()
projectRecordDT is my datatable populated with records using mySqlDataAdapter.
In my database, I would like to retrieve the last record of the column FloatNo.
Usually I am able to retrieve this by creating a new datarow. But how do I obtain it efficiently without having to loop the records every time by using datarows?

I have managed to solve my own question because I misplace a parenthesis with the column name.
The correct way is
Previous_Project_Float_Detail.Text = projectRecordDT.Rows(projectRecordDT.Rows.Count - 1)("FloatNo").ToString()
The column name is after the row count. Not inside.
Also, this only works if the order of the records is already correct in your database.

Related

MS Access Query function that skips records based on criteria

I am trying to test query function. IIf(IsNull([LTCMPlanSubmitted]),Date()-[LTCMPlanDue],[LTCMPlanSubmitted]-[LTCMPlanDue]) - This query runs successfully. Thing is it fills in data in records where technically should be blank for the field because the issue was cancelled.
Lets say the function in the query fills data in 8th field over in the table. can the Criteria be set up to look at ANOTHER field in the table?
Function is updating data in [DaysPlanlate] field - If value in a record in [OverallStatus] Field is "Closed-Cancelled" for THAT record then I want it to stay or be Blank. Is this possible to do? or should I be modifying the original function in the query instead? can you do "Nested Ifs" in Access?
I tried simple statement of [OverallStatus] = Not "Closed-Cancelled" in the Criteria but it just updated 0 rows
i was expecting the records that were Closed-Cancelled to become Blank. if i leave the query where it is it will just continually count up as each day passes.

Find out the specific row that was selected in Dash DataTable

I have a Dash DataTable with row_selectable set to "multi". Therefore, the user can select multiple rows via a checkbox that will appear next to each row of the DataTable.
I also have a callback that has as input Input("datatable-id", "selected_rows"). Therefore, each time the user selects a row, I get ALL the rows that are selected.
What I want to do is to update my database column is_selected based on the row that the user just selected. To get the row that the user just selected I can either:
Read my entire is_selected column of my database and find the difference between that and selected_rows.
Use selected_rows to update ALL the rows in my database.
I wonder, is there another better way to find out which specific row the user selected? So that I can simply update my single row in my database accordingly?
So, you can use a dcc.Store as a way to get access to the previous state.
If I'm not wrong, your problem is a comparison between two states: the state_0, the one before the interaction; and the state_1, the one after the interaction.
In that case, using only DashTable attributes, it is hard (at least I don't know how) to get the previous state of selected rows. With that in mind you can create a dcc.Store to store the last state of selected_rows to get access every time the callback is triggered. In other words, put the data as the Output off the callback and a State to get the access to state_0. Update the data with the current selected_rows after making a simple set difference between the current selected_rows and the previous one.

Fetching rows changed or added last day without time field?

I want query a table to find the changed rows last day. But there is no explicit time filed in column name. Is there any way I can access these data?
Without a field indicating when a record was changed there is no way to determine when a record was changed, therefore it is unfortunately impossible for you to query the records changed yesterday.

Sorting records on a form in MS Access 2010

I had a question last week about how to do a sort of ascending ID numbers by year for a SQL query.
Doing a secondary sort by year in a SQL query
I followed those instructions and the result was great for my table. The data in the resultant query was used to create a table that was then linked to a form. Unfortunately, as I add new records to the table, am I seeing that the sort is not respected after data entry (that is, new records are automatically displayed first when browsing records with the form instead of last). Is there a way to do a sort with ascending ID numbers and year within the form itself? When I try to use the ORDER BY year (date) expression in the form properties I'm getting an "undefined function in expression" error.
Since you already create a new table from the data, you could add a new column to that table containing the "year(date)" result. That way, you have a real column you can ORDER BY on. (ORDER BY yearcol, id)
When inserting, fill it with the current year.

How to display the records before 1 minute time using linq to sql?

In my table entering records with current datetime.i need to display it continuously what are the records are entering in db.
for that writing a webservice in that every 1minute i need to display the new entered records .
How to write linq to sql query to display before 1minute entered records?
you can save data in your database immediately but when you want to display data in Gridview you can make a delay with Thread.Sleep(60000);