How Is it Possible If I want to Attach My own db made in sql Server to my MVC3 application Is It Possible Then Kindly suggest me the Steps to do This process.Thank you.
You can attach your own database using ADO.NET or LINQ. For that simply update the connection string from web.config and add new .dbml file in Models folder. Drag all tables into .dbml file and after that by datacontext you can access your database in MVC3
application.
Revert in case your problem is not resolved.
Regards,
Rahul.
Please, Mark as Answer if this post helps you....!!!
You mean to say that I have to add ADO.NET Item in my models folder and then drag my tables to this file am I correct and then add name of database in web.config file.
Yes, you can add your database by adding .dbml file if you want to use LINQ. and .edmx file if you want to use entity data model. Both will give you expected output. Also you can add your custom modes along with database entities.
Please, Mark as Answer if this post helps you....!!!
I have this class
public DbSet<Employee> Employees { get; set;
public DbSet<Job> Jobs { get; set; }
And in Employee controller I have Declared the names and link these names also
var names = new List<Employee>
{
new Employee{Name="Azhar ul Haq"},
new Employee{Name="Saqib jillani"},
new Employee{Name="Wisal Ahmad"},
new Employee{Name="Akhtar sb"},
new Employee{Name="M Ali Qadar"},
new Employee{Name="Miss Sadaf"}
};
return View(names);
So Ho should I command my pic link to go to db column TimeIn.
Thank you.
I have this class
public DbSet<Employee> Employees { get; set;
public DbSet<Job> Jobs { get; set; }
And in Employee controller I have Declared the names and link these names also
var names = new List<Employee>
{
new Employee{Name="Azhar ul Haq"},
new Employee{Name="Saqib jillani"},
new Employee{Name="Wisal Ahmad"},
new Employee{Name="Akhtar sb"},
new Employee{Name="M Ali Qadar"},
new Employee{Name="Miss Sadaf"}
};
return View(names);
So Ho should I command my pic link to go to db column TimeIn.
Thank you.
qqaadir
Member
96 Points
150 Posts
MVC 3 Tutorial Movies database
Feb 23, 2012 09:24 AM|LINK
Split off from http://forums.asp.net/t/1646657.aspx/1?MVC+3+Tutorial+Movies+database#
Hi,
How Is it Possible If I want to Attach My own db made in sql Server to my MVC3 application Is It Possible Then Kindly suggest me the Steps to do This process.Thank you.
Regards.
Rahul Dhamal...
Member
65 Points
57 Posts
Re: MVC 3 Tutorial Movies database
Feb 23, 2012 12:44 PM|LINK
Hi,
You can attach your own database using ADO.NET or LINQ. For that simply update the connection string from web.config and add new .dbml file in Models folder. Drag all tables into .dbml file and after that by datacontext you can access your database in MVC3 application.
Revert in case your problem is not resolved.
Regards,
Rahul.
qqaadir
Member
96 Points
150 Posts
Re: MVC 3 Tutorial Movies database
Feb 23, 2012 05:59 PM|LINK
You mean to say that I have to add ADO.NET Item in my models folder and then drag my tables to this file am I correct and then add name of database in web.config file.
Rahul Dhamal...
Member
65 Points
57 Posts
Re: MVC 3 Tutorial Movies database
Feb 24, 2012 06:07 AM|LINK
Yes, you can add your database by adding .dbml file if you want to use LINQ. and .edmx file if you want to use entity data model. Both will give you expected output. Also you can add your custom modes along with database entities.
qqaadir
Member
96 Points
150 Posts
Re: MVC 3 Tutorial Movies database
Feb 24, 2012 10:06 AM|LINK
Hi,
I have added edmx file here in new project then have add this project to the reference of my first project.
In fact I am going to make a simple application in which I want that when I click on a linked image System time is noted in the db TimeIn column
I have linked the image and Now What Is the next after Making This db.Could you please guide me next.
Thank You.
Regards
qqaadir
Member
96 Points
150 Posts
Re: MVC 3 Tutorial Movies database
Feb 24, 2012 10:23 AM|LINK
I have this class
public DbSet<Employee> Employees { get; set;
public DbSet<Job> Jobs { get; set; }
And in Employee controller I have Declared the names and link these names also
var names = new List<Employee>
{
new Employee{Name="Azhar ul Haq"},
new Employee{Name="Saqib jillani"},
new Employee{Name="Wisal Ahmad"},
new Employee{Name="Akhtar sb"},
new Employee{Name="M Ali Qadar"},
new Employee{Name="Miss Sadaf"}
};
return View(names);
So Ho should I command my pic link to go to db column TimeIn.
Thank you.
qqaadir
Member
96 Points
150 Posts
Re: MVC 3 Tutorial Movies database
Feb 24, 2012 10:42 AM|LINK
I have this class
public DbSet<Employee> Employees { get; set;
public DbSet<Job> Jobs { get; set; }
And in Employee controller I have Declared the names and link these names also
var names = new List<Employee>
{
new Employee{Name="Azhar ul Haq"},
new Employee{Name="Saqib jillani"},
new Employee{Name="Wisal Ahmad"},
new Employee{Name="Akhtar sb"},
new Employee{Name="M Ali Qadar"},
new Employee{Name="Miss Sadaf"}
};
return View(names);
So Ho should I command my pic link to go to db column TimeIn.
Thank you.
Rahul Dhamal...
Member
65 Points
57 Posts
Re: MVC 3 Tutorial Movies database
Feb 24, 2012 11:51 AM|LINK
Hi,
you can use following code :
Then in Controller you can write the code to insert the system date into database table.
qqaadir
Member
96 Points
150 Posts
Re: MVC 3 Tutorial Movies database
Feb 24, 2012 12:00 PM|LINK
What should be here in the RouteUrl(...) and to insert the data How would I code please elaborate.
Thank you.
Rahul Dhamal...
Member
65 Points
57 Posts
Re: MVC 3 Tutorial Movies database
Feb 24, 2012 12:26 PM|LINK
Hi,
Use following example : And in Admin controller you can write the following code(here i have used the LINQ and not .edmx):
<a href="../Admin/Home"><img src="../Images/clock.png" alt="Clock" height="50px" width="50px" border="1" /></a> public ActionResult Home() { TMS_DBDataContext TMSDB = new TMS_DBDataContext(); TMS_EMPLOYEE tmsObj = new TMS_EMPLOYEE(); tmsObj.DOJ = System.DateTime.Now; TMSDB.TMS_EMPLOYEEs.InsertOnSubmit(tmsObj); TMSDB.SubmitChanges(); return View(); }