我如何使用C#在db中解答答案 [英] How I can dtore the answers in db using C#

查看:58
本文介绍了我如何使用C#在db中解答答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注册表包含user_Id,名称

reult表包含user_name,结果

但我不知道如何存储user_name

因为用户名文本框是在注册pg,我怎么能将它存储在结果表中



plzz帮我即时需要帮助plzzz给我解决方案plzzz



我尝试了什么:



我制作了结果表包含名称,结果

解决方案

不要。

设置两个表:

注册:

 Id int,IDENTITY 
UserName NVARCHAR



结果:

< pre lang =text> ID int,IDENTITY
UserId int,FOREIGN KEY to Signups.Id
ResDate DATETIME
Result ...



然后使用您在用户登录时获取的UserID将值插入结果中。根据您的系统,您保持用户ID为l ater - 您对Page的使用意味着这是基于Web的,因此您将在会话中存储UserId值,它将在会话到期之前保持可用。

当您需要显示结果时,你使用JOIN:

  SELECT  s.UserName,r.ResDate,r.Result  FROM 结果r 
JOIN 注册s
ON s.ID = r.UserId


signup table contain user_Id, name
reult table contain user_name , result
but i dont know that how i can store the user_name
because the username text box is in sign up pg from that how can i store it in the result table

plzz help me imediately i need the help plzzz give me the solution plzzz

What I have tried:

I make resulr table which contain name , result

解决方案

Don't.
Set up two tables:
Signups:

Id        int, IDENTITY
UserName  NVARCHAR


Results:

ID        int, IDENTITY
UserId    int, FOREIGN KEY to Signups.Id
ResDate   DATETIME
Result    ...


You then insert a value into the Results using the UserID you fetched when the user logged in. Depending on your system, you "hold onto" the userID for later - your use of "Page" implies this is web based, so you would store the UserId value in the Session and it will remain available until the session expires.
When you need to present the results, you use a JOIN:

SELECT s.UserName, r.ResDate, r.Result FROM Results r
JOIN Signups s
ON s.ID = r.UserId


这篇关于我如何使用C#在db中解答答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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