Frage

Die Seite arbeite ich an ist unter Windows Server 2003 und SQL Server 8 (2000?) Und ASP.NET 3.5.

Ich brauche eine Art von Skript oder die Anwendung ausgeführt haben Daten aus einer FTP'd Textdatei zu importieren, in die Datenbank. Es gibt bereits eine Website auf dem Computer ausgeführt wird, dass die aktuelle Datenbank verwendet. Kann ich eine geplante Aufgabe beginnen, um zuverlässig eine Art von ASPX-Seite, die die Daten importiert? Oder gibt es einen besseren Ansatz?

Was ist dafür zu sorgen, dass niemand sonst auf die Seite zugreifen kann, die den Import läuft? Ich möchte nicht zufällig Benutzer den Import läuft!

Vielen Dank im Voraus!

P. S. ein Teil der Verarbeitung muss auf den Daten auftreten, vor ihrem eingefügt. das heißt Lookups, conditionals, etc, so dass die DB-Tools nicht robust genug sind (glaube ich). Ich hasse DTS, und ich SSIS ist nicht verfügbar in dieser Version, denke ich.

War es hilfreich?

Lösung

DTS and stored procedures in a job.

BCP and stored procedures in a job.

You say you need to do alot of lookups and conversions? SQL is good at that - and good at doing it fast. It can seem a little intimidating at first, but it's not hard.

Andere Tipps

If you want to have a C# App handle your import I would suggest a windows application (exe) w/o a form (better than a console app because it does not pop up any UI whenever it runs). Have it run every so often (every minute) by a scheduled task.

Why would you use ASP.NET? Depending on the complexity of the job you could either load it directly to the database (BULK LOAD) or use DTS (SQL Server 2000) or SSIS (SQL Server 2005/2008) if more complex processing is needed.

run a BULK INSERT or bcp to import the data instead, see here http://msdn.microsoft.com/en-us/library/aa173839(SQL.80).aspx

I'll echo other people here - you don't want to have a scheduled task hit a web page. SQL Server provides some good data import options, or you could just write a simple windows program and run it as a scheduled task.

Another option would be to write a windows service that watches your FTP directory and does the import.

As others have said, probably a separate console application (triggered by a scheduled task) or a windows service would be the best option for this scenario.

On the other hand, if you already have all the required functionality available in the web app running on the server, then you could probably set up a scheduled task, that starts a script (VBscript, JScript), which in turn calls a page of the web app.

To have some sort of security (e.g. preventing that any user can call that page), you could add some code to the page, that checks if the page was called with http://localhost. This would at least prevent the page from being called from a remote client.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top