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 database 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
Related
I would like to know if this scenario would be possible in any programming language combined with any database technology.
I would like to automatically save received pdf files that are attached in emails into a database. Is this possible? Is there any library or framework available to do so?
Yes, I would recommend using Google Apps Script for this. The approach you should follow is to use the GmailApp class (Documentation here) to get the messages you need, you can use methods like getInboxThreads() (Documentation), to retrieve the messages.
After you've found the message and retrieved the attachment (which you can do withgetAttachments() (Documentation)), you can use the JDBC Service to connect with external databases. The specifics here depend a lot on what database you want to connect with, but the documentation will lead you in the right direction.
To give you the question first: I want to know if it is possible to create a stored procedure or something in SQL Server that intercepts and translates SELECT, INSERT, and UPDATE commands. Now for the explanation:
I am writing a web application to replace an old desktop app. Its a business app which is basically a database interface with reports and searches and all the good ol' CRUD. The new and old apps need to live in harmony together since some customers may be using the old and new together to access the same DB.
My problem is that the original database format stores most data in a single blob of text (1 nvarchar(MAX) field). I want to add functionality to search on fields stored in the blob, but it will be cumbersome and slow. I would like to update the database format without changing the desktop app at all, hence the question above.
It occurs to me that I could do this on the client by writing a wrapper class for the data access object and then do a bulk replace in the client code to reference the wrapper, but I want to know what my options are on the server as well.
In case anyone wants to know, the old app is in VB6 and the new in C#.
EDIT
Alright, so it looks like if I do anything on the server side we are looking at adding stored procedures and then updating the client VB6 code to reference the stored procs. Do something like a bulk replace of SELECT with sp_oldselect ... To return the data in a different format. I'm guessing a client-side wrapper would be the best solution for the time-being. Old apps die hard.
You can create a bunch of views for the old client and let it to query those views. It will be slow as hell in most cases, but it can 'replace' the select query. For updates and insert.. well.. instead of triggers on the views could help is some cases, but it will require lots of processing.
However my suggestion is to provide exactly the same functionality in the web app and deprecate the desktop app. When the desktop app's share is low enough, stop supporting it. From this point, you are (mostly) free to add new functions, upgrade the database schema, etc.
I agree with JonH, that alot can go wrong here, but you can try and read up on the INSTEAD OF Triggers in MS SQL server here: https://technet.microsoft.com/en-us/library/ms179288(v=sql.105).aspx
The title says it all. I need to create a form that the user fills in and on submit, I want the data to go to a database and a PDF to a directory on the server.
I don't think AngularJS can do all of these things, can it? I'm very new to programming -- trying to crossover from HTML/CSS/JS to more in-depth projects.
Can anyone please suggest the best course for this? What language for the form, writing to the DB and generating a PDF? I can do the rest of the research and build it out once I have some direction.
How would you go about achieving this?
Thanks!
Ugh. I forgot to mention that PHP is not an option. Is there another way?
All you need is to apply the paradigm Client / Server.
With angular.js you can build the client software for handling the form but this is not necessary...
With a single script php you can generate the page with the form and handling the incoming data.
You can use a standard relational database like mysql for storing it and, about the pdf, take a look here
I have a SQLite Database that I access using System.Data.SQLite. The database is read into my Entity Framework Objectcontext. However, I also need direct access to the database in certain cases.
Can I / Should I use the same connection that my Entity Framework object context is using? I.e. ObjectContext.Connection?
If yes, how can I access it? Casting Entities.Connection to SQLiteConnection results in "Unable to cast object of type 'System.Data.EntityClient.EntityConnection' to type 'System.Data.SQLite.SQLiteConnection'."
If not, should I create a seperate connection, open it and keep it open for the application duration, or should I open and close the connection every time I want to access the database with it?
ObjectContext.Connection is an EntityConnection. You can get the store connection via:
var sc = ((EntityConnection)ObjectContext.Connection).StoreConnection;
You can cast that to the SQLiteConnection.
It's OK to use this connection if you need it.
But, as #Chris mentioned, you can just use ObjectContext.ExecuteStoreQuery, etc., if that will do for you.
If you're using the DBContext API you can actually execute a direct query by using this: aDBContext.Database.SqlQuery
I wouldn't be surprised if something similar exists for the ObjectContext API, but I barely used that one and thus can't tell you what it is.
Now if for some reason you can't (or don't want) to do that, I'd create a new connection for your custom queries. Put them in a Using and close it as soon as you're done with it.
Entity Framework has built in methods for executing raw SQL queries if that's what you need to do.
I have a Winforms app which is being deployed to the employees as a smart-client application. It uses a SQL Server Compact database to store data. I need to add a feature to the app which will allow user to export a particular part of his data to a file and send it via e-mail to his colleague. The other user should be able to import the data, make some changes a send it back. I'm in the process of making a decision which way to go here.
I'm thinking of letting them export SQLce databases (*.sdf) with only the single record. It may be safer to send binary and password protected data and pretty easier to implement as well. Do you think it is a good idea or should I stick with more common solutions - e.g. use XML to export and import the data? Am I missing something important if I'll go with sending the *.sdf?
Sounds like a good idea to me! http://blogs.msdn.com/b/stevelasker/archive/2008/01/15/msdn-webcast-introducing-sql-server-compact-3-5.aspx (Using SQL CE as a custom doc format)