如何在不创建表的情况下存储数据 [英] how to store data without creating tables

查看:80
本文介绍了如何在不创建表的情况下存储数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我有2个文本框和一个按钮。当我在文本框中输入值时,它应该从中获取详细信息DB并存储该行。当我搜索产品时,还应显示以前搜索过的产品(在Gridview中)。







如何在不在数据库中创建表的情况下实现此目的?

Hi,


I have 2 text boxes and one button.When i enter value in textbox it should fetch the details from DB and store that row.Again when i search for a product the previous searched product should also be displayed (In Gridview).



How do i achieve this without creating a table in database ??

推荐答案

您可以创建 in-memory DataTable 并将后者绑定到 GridView
You could create a in-memory DataTable and bind the latter to the GridView.


这是搜索只是为了每个会话,或者必须为所有用户提供相同的值集?如果是每个会话,那么只需将结果存储在会话中。如果它适用于所有用户,请将结果存储在缓存
Is this search just meant to be per-session, or must the same set of values be available for all users? If it's per-session, then just store the results in the Session. If it's meant to be for all users, store the results in the Cache.


CPallini的解决方案将起作用。



但是,如果你在谈论太多这样的记录,那么你可能想要暂时存储在XML中并继续显示来自这个XML的数据在Datagrid上。



我的意思是:

1.首次从数据库中显示搜索结果并显示。也将其写入XML。

2.在第二个搜索事件中,从DB获取结果,将其添加到XML,然后从此XML显示。



请注意,只有在您的网站上有许多此类操作时才会这样做。否则,内存数据表就足够了。
CPallini's solution will work.

However, just in case you are talking about too many such records then may be you want to look at storing in an XML temporarily and keep displaying the data from this XML on the Datagrid.

What I mean is:
1. Fetch the search result first time from the DB and display. Also write it into the XML.
2. On the 2nd search event fetch the results from the DB, add it to the XML and then display from this XML.

Please note that this is only if there are many such operations on your site. Otherwise an in-memory data table is sufficient.


这篇关于如何在不创建表的情况下存储数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆