在C#中动态创建数据库表 [英] Dynamic creating table in database in C#

查看:280
本文介绍了在C#中动态创建数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



i我在其中开发一个网站我希望在新用户注册时能够将更新删除联系信息添加到他的个人资料中。



喜欢在gmail中新用户创建注册时他可以添加更新删除他的朋友的电子邮件ID信息。



那该怎么办?



thanxx



SHOUTING删除 - OriginalGriff [/ edit]

hello

i am devloping a website in it I want to do when new user register he can add update delete contact information to only his profile.

like in gmail when new user create Sign up he can add update delete his friends email id information like that.

so what should do??

thanxx

[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

这意味着先生,当新用户正常运行时,c#会自动为该特定用户创建数据库。



这是一个非常糟糕的主意! :笑:

为每个用户创建一个数据库甚至一个表都是对空间,内存和时间的巨大浪费。



如果你想要一个特定于每个用户的联系人列表然后创建一个包含交叉引用的表:

用户表:

"that means sir when new user sine up, c# create automatically database for that particular user."

That is a spectacularly bad idea! :laugh:
Creating a database or even a table for each user is a massive waste of space, memory, and time.

If you want a list of "contacts" which is specific to each user then create a table which holds cross references:
User Table:
ID      Name     Email
1       Joe      Joe@Domain.com
2       Mike     Mike@OtherDomain.com
...
1000    Fred     FredTheShred@RBS.com





联系人表格:



Contacts table:

ID      UserID   ContactID
1       1        2
2       1        1000
3       1        777
4       2        1000
5       2        666

在此示例中,用户1(Joe)知道用户2(Mike),另一个用户2 id 777和用户1000(Fred)。

用户2(Mike)知道Fred和另一个ID为666的用户

要找出用户有哪些联系人,您从联系人表中选择记录,仅询问那些记录h他的用户ID:

In this example, User 1 (Joe) knows user 2 (Mike), another user with the id 777 and user 1000 (Fred).
User 2 (Mike) knows Fred, and another user with the ID 666)
To find out which contacts a user has, you select the records from the Contacts table, asking only for those records with his User ID:

SELECT ContactID FROM Contacts WHERE UserID=1


这篇关于在C#中动态创建数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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