This is a migrated thread and some comments may be shown as answers.

Insert TIME STAMPS in table as well as user inputted data

3 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
matt
Top achievements
Rank 1
matt asked on 16 Sep 2010, 05:27 PM
I am using the declarative way ofdoing CRUD operation but I need to add a time stamp to a particular column as well.. Is there any east was to do this in the declarative framework??

Otherwise I guess I need to do everything programmatically and lose all the benefits of doing it declaratively.

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 22 Sep 2010, 07:40 AM
Hi Matt,

The first option is to add a handler for the appropriate event on the data source control and update the filed manually:
protected void dataSourceID_Inserting(object sender,SqlDataSourceCommandEventArgs e)
{
     e.Command.Parameters["@date_filed"].Value = DateTime.Now.ToString();
}

The other option is to use the SQL Trigger which is fired after Insert or Update operations and changes the field for the inserted or updated row.

Also you could use the sql column with type timestamp. The value in the timestamp column is updated every time a row containing a timestamp column is inserted or updated. For more information please check out the following article:
http://msdn.microsoft.com/en-us/library/aa260631%28SQL.80%29.aspx

I hope this helps.

Best wishes,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
matt
Top achievements
Rank 1
answered on 22 Sep 2010, 02:47 PM
Ok so I just need to use a custom stored procedure... obviously there is no way to do custom things purely declaritivly unless tables map 1-to-1 with your grid..

I wish there were more examples that showed dealing with CRUD operations and grids that DID NOT map 1-to-1 with a table

The only EF CRUD example I can find is a 1-to-1 declarative way of doing things.

0
Radoslav
Telerik team
answered on 27 Sep 2010, 01:05 PM
Hi Matt,

The stored procedure is a really good choice. With them you could perform almost every operation over your database. The RadGrid just pass the parameters to the stored procedure and then the stored procedure handle the CRUD operation and could execute a complex logic. On the following links you could find the advantages of the stored procedures:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.dc.doc/dc/c_spbenefits.htm
http://searchsqlserver.techtarget.com/news/1052737/Why-use-stored-procedures

Additionally when you use the purely declarative approach, you can often avoid writing any data access code.
However, you also sacrifice a fair bit of flexibility. Here are the most significant disadvantages:
  • Data access logic embedded in the page: To create a data source control for example SqlDataSource control, you need to hard-code the SQL statements in your web page. This means you could not fine-tune your query without modifying your web page. In an enterprise application, this limitation is not acceptable, as it’s common to revise the queries after the application is deployed in response to profiling, indexes,and expected loads. In a large-scale web application, the data access code will be maintained, tested, and refined separately rom the business logic (and it may even be coded by different developers). The data source control just does not give you that level of flexibility.
  •  Maintenance in large applications: Every page that accesses the database needs its own set of DataSource controls. This can turn into a maintenance nightmare, particularly if you have several pages using the same query (each of which requires a duplicate instance of the data source  control). In a component-based application, you’ll use a higher-level model. The web pages will communicate with a data access library, which will contain all the database details.
  • Lack of flexibility: Every data access task requires a separate data source control. If you want to provide a user with multiple ways to view or query data, this can swamp your page with data source objects, one for each command variant.
  • Inapplicability to other data tasks: The data source controls does not properly represent some types of tasks. The SqlDataSource is intended for data display and data editing scenarios. However, this model breaks down if you need to connect to the database and perform another task, such as placing a shipment request into an order pipeline or logging an event. In these situations, you’ll need custom database code. It will simplify your application if you have a single database library that encapsulates these tasks along with data retrieval and updating operations. In a well-abstracted three-tier application, your web page may call a method such as Business.PlaceOrder() without worrying about whether this operation involves saving an order record in a database, sending a message to a message queue, communicating with a remote component, or using a combination of all these tasks.To get around these limitations, you should consider the ObjectDataSource. The ObjectDataSource allows you to bind your page to a custom data access component. Best of all, you get almost all the same frills, such as design-time data binding and no need to write code in your web page.

I hope this helps.

Regards,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
matt
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
matt
Top achievements
Rank 1
Share this question
or