NHibernate SqlExeption was unhandled -
i study nhibernate , try repeat creating application video course,
created database, model, xml-file , wrote code
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 key exit..."); console.readkey(); } } } }
but when tried debug got sqlexeption unhandled
i suppose need add login , password in code, can explain me how it?
you using integrated securty, user running code has have access:
server=localhost; database=nhibernatedemo; integrated security = sspi
you can change connection string use sql account or give user access database.
configure connectionstrings: connectionstrings
Comments
Post a Comment