SQL database og MVC problem.
Hej når jeg forsøger at køre en side så får jeg denne fejl.Server Error in '/' Application.
--------------------------------------------------------------------------------
Ugyldig værdi for nøglen 'integrated security'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Ugyldig værdi for nøglen 'integrated security'.
Source Error:
Line 14: public SqlProductsRepository(string connectionString)
Line 15: {
Line 16: productsTable = (new DataContext(connectionString)).GetTable<Product>();
Line 17: }
Line 18: public IQueryable<Product> Products
Source File: C:\***\Projects\Store\DomainModel\Concrete\SqlProductsRepository.cs Line: 16
Min SqlProductsRepository.cs er dette
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DomainModel.Abstract;
using DomainModel.Entities;
using System.Data.Linq;
namespace DomainModel.Concrete
{
public class SqlProductsRepository : IProductsRepository
{
private Table<Product> productsTable;
public SqlProductsRepository(string connectionString)
{
productsTable = (new DataContext(connectionString)).GetTable<Product>();
}
public IQueryable<Product> Products
{
get { return productsTable; }
}
}
}
Min database connection ProductsController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DomainModel.Abstract;
using DomainModel.Concrete;
namespace WebUI.Controllers
{
public class ProductsController : Controller
{
private IProductsRepository productsRepository;
public ProductsController()
{
string connString = @"Server=.\SQLEXPRESS;Database=SportsStore;Trusted_Connection=Uid=myUsername;Pwd=myPassword;";
productsRepository = new SqlProductsRepository(connString);
}
public ViewResult List()
{
return View(productsRepository.Products.ToList());
}
}
}
nogle der kan se hvad fejlen evt. er, skriv hvis I skal have mere kode fra de andre sider.