0
我學習NHibernate和嘗試重複創建從視頻過程中的應用,
我創建的數據庫,模型,XML文件,然後我寫了這個代碼NHibernate的SqlExeption了未處理
using System;
using System.Reflection;
using NHibernate.Cfg;
using NHibernate.Dialect;
using NHibernate.Driver;
namespace NHibernateDemo
{
internal class Program
{
static void Main(string[] args)
{
var cfg = new Configuration();
cfg.DataBaseIntegration(x =>
{
x.ConnectionString = "Server=localhost; Database=NHibernateDemo; Integrated Security = SSPI";
x.Driver<SqlClientDriver>();
x.Dialect<MsSql2008Dialect>();
});
cfg.AddAssembly(Assembly.GetExecutingAssembly());
var sessionFactory = cfg.BuildSessionFactory();
using (var session = sessionFactory.OpenSession())
using (var tx = session.BeginTransaction())
{
var customers = session.CreateCriteria<Customer>()
.List<Customer>();
foreach (var customer in customers)
{
Console.WriteLine("{0} {1}", customer.FirstName, customer.LastName);
}
tx.Commit();
Console.WriteLine("Enter any key to exit...");
Console.ReadKey();
}
}
}
}
但是當我試圖調試它我得到SqlExeption了未處理
我想我需要在我的代碼添加登錄名和密碼,但有人可以解釋我該怎麼做?
你能解釋一下我應該怎麼改變我的連接字符串? – Heidel