只想向数据库添加一条记录 [英] just want to add one record to database

查看:69
本文介绍了只想向数据库添加一条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何只向数据库添加一条记录.

例如,当我将我的名字写到txtName时,我单击按钮,它将保存到nameField ...在我再写一次我的名字后,它将覆盖相同的字段..我该怎么办?在数据库İdentity中增加1,2,3,4,5 ..,我只想要一个地方.

hi guys ,

how can i add only one record to database.

For example , when i write myname to txtName then i click the button , it will save to the nameField...after i write another time my name it will overwrite the same field..how can i do it ? in database İdentity increases 1,2,3,4,5.. , i just want only one place.

推荐答案

在将数据插入表之前,只需删除该表.

Just delete the table before you insert data into it.

Delete from [Your Table Name]

INSERT INTO [Your Table Name]
(
   Name
)
VALUES
(
   @Name
)


正如 aspnet_regiis 所建议的那样,我们将其称为 ^ ].
As aspnet_regiis already suggested, we call it UPDATE[^].




在这种情况下,您应该在数据库中使用一些KeyValue对.无需创建信息的列数,而仅创建两列.一个用于,另一个用于其值.

默认情况下,您的表具有一些默认值.而且每次您都可以更新表格中的信息.

仅在没有其他选项可保存数据库以外的信息时,才应使用此方案.

Hi,

In such scenario you should use some KeyValue pair in the database. Instead of creating number of columns for the information, create only two column. one for Key and another with it''s Value.

By default your table have some default value. And each time you can update the information from the table.

You should use this scenario only when you do not have any option to save the information other then database.

--------------------
key      | value
--------------------
username | abc
otherinfo| infovalue
nextinfo | nextvalue
---------------------



许多人可能不接受这种方法,但这是我个人的看法

谢谢



Many people may not accept this methodology but this is my personal opinion

Thanks


这篇关于只想向数据库添加一条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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