Click here to Skip to main content
15,911,762 members
Home / Discussions / C#
   

C#

 
GeneralRe: ICON!!! Pin
Luc Pattyn8-Oct-07 14:03
sitebuilderLuc Pattyn8-Oct-07 14:03 
GeneralRe: ICON!!! Pin
MasterSharp8-Oct-07 14:11
MasterSharp8-Oct-07 14:11 
GeneralRe: ICON!!! Pin
Luc Pattyn8-Oct-07 14:24
sitebuilderLuc Pattyn8-Oct-07 14:24 
GeneralRe: ICON!!! Pin
MasterSharp8-Oct-07 14:29
MasterSharp8-Oct-07 14:29 
GeneralRe: ICON!!! Pin
Luc Pattyn8-Oct-07 15:32
sitebuilderLuc Pattyn8-Oct-07 15:32 
QuestionDataGridView to DataSet Pin
udikantz8-Oct-07 13:42
udikantz8-Oct-07 13:42 
QuestionFileSystemWatcher to SQL 2005 Pin
solutionsville8-Oct-07 13:11
solutionsville8-Oct-07 13:11 
AnswerRe: FileSystemWatcher to SQL 2005 Pin
ChrisKo8-Oct-07 14:20
ChrisKo8-Oct-07 14:20 
I assume an outside process is appending to this file and you want to then import that new information to SQL?

The FSW will of course tell you the file has changed. You will then need to verify that outside process has completed using the file. You do this by attempting to open the file for writing and only proceed when you have an exclusive lock on the file.

Now at this point, there are a few ways to do it (your choice depends on how you exactly get the data), but I will describe what I found to be the easiest for me. If it's the first time opening a file just import the entire contents into SQL and then I will write a comment line that is the timestamp of when I imported that batch (ie. # MM/dd/yyyy HH:mm:ss (# of records) imported)

So I know the next time the FSW kicks off my process, I just jump to the last comment marker I wrote to the file and ready everything appended after that.

Another option is to get the last record date from SQL and only read the records from the file with a greater date. If your text file isn't sequential, this approach could add more code to sort the file by date or another approach.

You could also create an import table in the database that has the timestamp and the line number offset from the previous import and use that number to jump within the text file.

Hope I've given you some ideas on how you can approach the file importing.

Also, just in case I misunderstood and you wanted code specific stuff and not appracoh opinions then look into the TextReader and TextWriter classes, along with ADO.NET
AnswerRe: FileSystemWatcher to SQL 2005 Pin
solutionsville8-Oct-07 15:39
solutionsville8-Oct-07 15:39 
QuestionEdit the Registry keys Name/Type/Data fields. Pin
Dino2Dino8-Oct-07 11:51
Dino2Dino8-Oct-07 11:51 
AnswerRe: Edit the Registry keys Name/Type/Data fields. Pin
Scott Dorman8-Oct-07 12:11
professionalScott Dorman8-Oct-07 12:11 
QuestionRe: Edit the Registry keys Name/Type/Data fields. Pin
Dino2Dino8-Oct-07 13:14
Dino2Dino8-Oct-07 13:14 
AnswerRe: Edit the Registry keys Name/Type/Data fields. Pin
Scott Dorman8-Oct-07 13:23
professionalScott Dorman8-Oct-07 13:23 
GeneralRe: Edit the Registry keys Name/Type/Data fields. Pin
Dino2Dino8-Oct-07 13:30
Dino2Dino8-Oct-07 13:30 
GeneralRe: Edit the Registry keys Name/Type/Data fields. Pin
Dave Kreskowiak8-Oct-07 13:48
mveDave Kreskowiak8-Oct-07 13:48 
GeneralRe: Edit the Registry keys Name/Type/Data fields. Pin
Dino2Dino9-Oct-07 10:16
Dino2Dino9-Oct-07 10:16 
GeneralRe: Edit the Registry keys Name/Type/Data fields. Pin
Dave Kreskowiak9-Oct-07 11:47
mveDave Kreskowiak9-Oct-07 11:47 
GeneralRe: Edit the Registry keys Name/Type/Data fields. Pin
Dino2Dino12-Oct-07 10:59
Dino2Dino12-Oct-07 10:59 
AnswerRe: Edit the Registry keys Name/Type/Data fields. Pin
ChrisKo8-Oct-07 14:08
ChrisKo8-Oct-07 14:08 
GeneralRe: Edit the Registry keys Name/Type/Data fields. Pin
Dino2Dino9-Oct-07 10:19
Dino2Dino9-Oct-07 10:19 
QuestionMagnifying glass control needed - recommendations please Pin
ferrour668-Oct-07 11:00
ferrour668-Oct-07 11:00 
AnswerRe: Magnifying glass control needed - recommendations please Pin
TJoe10-Oct-07 8:55
TJoe10-Oct-07 8:55 
Questionconvert image format [modified] Pin
cmarmr8-Oct-07 10:41
cmarmr8-Oct-07 10:41 
AnswerRe: convert image format Pin
Guffa8-Oct-07 12:31
Guffa8-Oct-07 12:31 
GeneralRe: convert image format Pin
cmarmr9-Oct-07 2:38
cmarmr9-Oct-07 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.