Orchard connection to the database
I'm trying to build a web application using Orchard, but I have a page that saves data in a database. How can I connect to the databa开发者_如何学编程se and save this data to it using Orchard?
Thanks
To pass the data to another database you need to be careful as your quite likely to end up with transaction errors.
Create a normal ADO connection using whatever method you would normally do to do it, and then wrap this in a supress transaction. This is because Orchard uses a per request transaction which means you will always be inside a transaction, this means that once you try to connect to a second database the connection will try to elevate to MSDTC, if this is okay then you dont need the suppress statement, but if you dont have this configured... then supress it.
It depends. What kind of data? Do you want to let Orchard take care of the data persistence or do you want to handle your own database? If you want to handle it yourself, well, just do: it's just MVC. If you want to let Orchard do it, the easiest is to handle that data as a content type and there are plenty of tutorials in the Orchard docs for that sort of thing.
Take a look at the Contact Form module in the gallery, it is a great reference.
http://orchardproject.net/gallery/List/Modules/Orchard.Module.CyberStride.Contacts
精彩评论