How to show edited Row and before edited row in gridview? - asp.net

I am working with ASP.NET and SQL Server 2012.
I have a form which has operation like Insert, Update and Delete.
While using Update, I need to display 2 rows; one row displaying previous row on which update has been performed, and the second row will be the updated row.
I am sharing my table column headings.
ServiceTaxCode Name Location CentralisedRegDate SurrenderDate
AA ARMI mumbai 2015-03-10 2016-04-03

Related

How do I populate an empty column in my sql database?

How do I populate an empty column in my sql database?
I have a list that I want in the last column of my database. If I use executemany it just adds rows on the bottom of my database. Is there a way to fill it from the top? The column is currently populated with NULL values.
Just to be clear. I want the first item in the list to be put in the first row and item n on the list to be put into row n.
Thanks in advance
*Always take backup of your database, just incase you want to revert it back to original state.
Each row in your database table should have a unique primary key. As you mentioned you have a list to be uploaded in the last column, I assume you have some kind of relationship that distinguishes which list item goes to which row in the last column of the table.
You an update a single row by simple update syntax as below:
UPDATE table_name
SET last_column = somevalue_from_list
WHERE id = unique_row_id;
If you want to update all the rows with the same value then
UPDATE table_name
SET last_column = one_value_for_all_rows;
Follow the below suggestion only when you are using phpmyadmin to manage your tables:
If you want to update each row with the unique value from the list then my suggestion will be to export your table in csv format, open in excel like software and add your last column values in last column of each row and then import the changed table back to the database.
Hope this help.

create empty row in dbgrid

I wanted to insert several lines to database using DBGrid.
on my query, I selected for example:
select * from cust where id='0';
that code will return no record at all so my dbgrid will not show anything but an empty row. Now I wanted to put in data in empty row with new data. However my data needs 2 lines from dbgrid. I wanted dbgrid creates an empty row right after I fill last column in first row. How do I code that? (without inserting the first row data because later I'll insert everything with a seperated button).
thanks!
you can add records in your table with NULLin each column.
For example, suppose the table where the DBGrid is binded to has 4 columns, than you can try this code to add empty records
Query1.InsertRecord([null, null, null, null]);
With this code you can add as many empty records as you like in the DBGrid
That is assuming that the query component you are using supports the InsertRecord method...

Access query to include all records even if 1 field has missing data

How can I get MS Access 2010 to include data in a query if 1 field has missing data.
IE: I have a sn column in tblPropertydevices and a sn column in tblBrentwoodID that is imported from another source. If there is a typo in the imported data sn column, the entire report is not printed.
I would like for the report to print all reports & ignore the missing data in the one column. I have tried "<>"" Or is null" in the criteria for that column wth no results.
The query pulls data from several tables and prints test reports based on date tested and tech#. That is the only 2 fields that absolutely have to match.
Found the solution.
All you have to do is click on the relationship line in the query and select the 2nd radio button to include all records from the firs table.
Too easy
Toby

Gridview row having multiple record

I have a stored procedure that retrieves employee information - I don’t want to edit this stored procedure because it is globally use with in the website.
Here is now my dilemma, how can I put multiple row records in a column in the grid view. Is Gridview powerful enough to my scenario below or I really need to edit the stored procedure or my copy of it. Thanks
Records retrieve by stored procedure
Employee_ID Purchase ID Amount
1 0123456 100
1 012356 560
1 012446 560
1 012126 560
2 011122 100
2 051122 200
I want to achieve this in gridview
Employee ID Purchase ID Total Amount
-----------------------------------------
1 012345 1780
012346
012446
012126
2 011122 3000
051122
You could create a new stored procedure for use with this gridview only, leaving your existing stored procedure as-is so it doesn't break other parts of your code.
Alternatively, if you don't want to create a new stored procedure, you could sum the totals in your vb code, although it will be more work than doing it at the DB level. You'd do this using the gridview's datasource, not the gridview itself.
You can add a template column, and start it with (I believe) an </td></tr><tr><td>
In any case, each gridview template column implicitly (you can't see it) renders open/close td tags around whatever you put in it.

Data Migration in sql 2005

In my Live sql database ,I have to change the date value from (date, month ,year) to date.
Now there is 100 records with the date as date,month ,year(3 Fields).iF I change directly to date Field all the datas in the 3 field of those 100 records will automaticly change to a default date and original dates will disappear.What should i do to migrate all my datas safely
Add the new column (ALTER TABLE), populate it, and drop the old ones when you are ready to do so.
Make a backup. Add the new column, allowing the value to be null. Update the new column using a date constructed from the existing columns for month/day/year. Change the new date column to disallow nulls (if appropriate). Update your code to use the new column instead of the old column, then remove the old columns. If it is not possible to update all of your code, you may need to add triggers to keep the old and new columns in sync.

Resources