English 中文(简体)
在数据库中添加物体价值
原标题:add object values to a database

我正在将申请人的盒式数据储存在课堂。 我称之为会议,把会议分为一个目标。

如何通过这些项目,并将其输入数据库?

是否可穿透和装入扼杀? 我正在使用数据存取层和一个分析仪数据库。

此处为“DAL”中插入的插图。 我全心全意全心全意,因为我知道现在要通过什么。 但是,这确实具有一种运行频率功能,可以把扼制的泥浆带进去。

public void AddJobApplication()
{
string sql = "insert into JOBQUESTIONS (JOBAPPLICATIONID, QUESTIONTEXT, TYPEID, HASCORRECTANSWER, CORRECTANSWER, ISREQUIRED) VALUES (" + JobID + ",  " + QuestionText + " , " + TypeID + ", " + HasCorrectAnswer + ",  " + CorrectAnswer + " , " + IsRequired + ")";
 RunQuery(sql);

iii

这里是我的班子

public class JobApplicantSession
{

    public JobApplication ApplicationSession
    {

      get {if (HttpContext.Current.Session["Application"] != null)
               return (JobApplication)HttpContext.Current.Session["Application"];
           return null; iii

      set{ HttpContext.Current.Session["Application"] = value; iii
    iii


iii

Then, i can retrieve that session and store it in an object

JobApplicantSession _sessions = new JobApplicantSession();
JobApplication _application;
_application = new JobApplication(jobID);
_sessions.ApplicationSession = _application;   //_application holds all my saved textbox texts

JobApplication application;

var jas = new JobApplicantSession();
application = jas.ApplicationSession;   //holds all my session text

我想在表JOB RequestTIONS中插入多个记录,在应用变量中拥有所有这些记录。

谢谢!

最佳回答

Couple of things:
First its seems that JobApplication is an object which is holding data for a particular job application. You can t do iteration on that. You probably need a list of JobApplication and your object application should be something similar to
List<JobApplication> applications = new List<JobApplication>();
You can only iterate using foreach through an object if it has Ienumerable interface implemented. (Generally speaking an Array of objects or List of Objects)

为了在数据库中添加数据,一旦你能够进行检索和构造查询,我建议建立一个具有多重价值的单一加插说明。 然后将数据输入数据库。 请确实注意SQL Injection。 另外,如果你认为,使用多份声明符合你的需要,则使用

问题回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签