Click here to Skip to main content
15,909,835 members
Home / Discussions / C#
   

C#

 
AnswerRe: Extracting files from inside a file archive Pin
Roger CS13-Oct-07 11:52
Roger CS13-Oct-07 11:52 
GeneralRe: Extracting files from inside a file archive Pin
Luminare14-Oct-07 10:48
Luminare14-Oct-07 10:48 
QuestionSystem.IO.Exception Pin
solutionsville12-Oct-07 13:53
solutionsville12-Oct-07 13:53 
AnswerRe: System.IO.Exception Pin
Dave Kreskowiak12-Oct-07 15:35
mveDave Kreskowiak12-Oct-07 15:35 
GeneralRe: System.IO.Exception Pin
solutionsville12-Oct-07 16:02
solutionsville12-Oct-07 16:02 
GeneralRe: System.IO.Exception Pin
Dave Kreskowiak12-Oct-07 17:00
mveDave Kreskowiak12-Oct-07 17:00 
GeneralRe: System.IO.Exception Pin
solutionsville12-Oct-07 17:07
solutionsville12-Oct-07 17:07 
GeneralRe: System.IO.Exception Pin
Dave Kreskowiak13-Oct-07 3:01
mveDave Kreskowiak13-Oct-07 3:01 
That solution will only work so long as the other process cooperates and performs EXACTLY as expected. Once the system gets booged down or the other process changes, your solution breaks instantly. That's why I said you MUST write your code to retry opening the file, NOT wait a predetermined amount of time. Your code is not written defensively and is actually hoping the future NEVER changes. Good luck with that.

Your SQL statement is written incorrectly. It's much better practice to specify the column names in your table and then the parameter names assigned to them. If your SQL table changes, it won't immediately break your code. You also have incorrectly created the parmater objects. Change the SQL to: (I'm making assumptions about your column names and types!!)
INSERT INTO AlarmsList (DateTime, Address, Location, State, AlarmMessage)
    VALUES (@DateTime,@Address,@Location,@State,@AlarmMessage)

The names with the @ in front of them are your parameter place holders. You have to create these exact parameters in your code and give them the appropriate values. BTW, why are you storing your DateTimes as a string in the database?? Bad practice!
command.Parameters.AddWithValue("@DateTime, tokens[0]);
command.Parameters.AddWithValue("@Address", tokens[1]);
command.Parameters.AddWithValue("@Address", tokens[2]);
command.Parameters.AddWithValue("@Address", tokens[3]);
// 4 and 5 get skipped because you're not using them, so why take up the bandwidth passing them?
command.Parameters.AddWithValue("@Address", tokens[6]);

Putting in that line with the ?: in it was useless. Go back to the tokenizing code and validate you can fill in all the fields back there.


A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


AnswerRe: System.IO.Exception Pin
solutionsville13-Oct-07 9:44
solutionsville13-Oct-07 9:44 
QuestionProblem with launching an external process Pin
Togakangaroo12-Oct-07 10:44
Togakangaroo12-Oct-07 10:44 
AnswerRe: Problem with launching an external process Pin
Ennis Ray Lynch, Jr.12-Oct-07 11:28
Ennis Ray Lynch, Jr.12-Oct-07 11:28 
AnswerRe: Problem with launching an external process Pin
Daniel Grunwald12-Oct-07 23:53
Daniel Grunwald12-Oct-07 23:53 
AnswerRe: Problem with launching an external process Pin
Togakangaroo15-Oct-07 4:34
Togakangaroo15-Oct-07 4:34 
AnswerRe: Problem with launching an external process Pin
Togakangaroo15-Oct-07 7:09
Togakangaroo15-Oct-07 7:09 
QuestionButton Questions Pin
C# Beginner Nick12-Oct-07 10:08
C# Beginner Nick12-Oct-07 10:08 
AnswerRe: Button Questions Pin
Kristian Sixhøj12-Oct-07 10:13
Kristian Sixhøj12-Oct-07 10:13 
GeneralRe: Button Questions Pin
C# Beginner Nick12-Oct-07 10:16
C# Beginner Nick12-Oct-07 10:16 
GeneralRe: Button Questions Pin
Kristian Sixhøj12-Oct-07 10:17
Kristian Sixhøj12-Oct-07 10:17 
GeneralRe: Button Questions Pin
User 665812-Oct-07 10:52
User 665812-Oct-07 10:52 
GeneralRe: Button Questions Pin
Kristian Sixhøj12-Oct-07 10:57
Kristian Sixhøj12-Oct-07 10:57 
AnswerRe: Button Questions Pin
Kristian Sixhøj12-Oct-07 10:21
Kristian Sixhøj12-Oct-07 10:21 
GeneralRe: Button Questions Pin
C# Beginner Nick12-Oct-07 10:46
C# Beginner Nick12-Oct-07 10:46 
GeneralRe: Button Questions Pin
Kristian Sixhøj12-Oct-07 10:47
Kristian Sixhøj12-Oct-07 10:47 
GeneralRe: Button Questions Pin
C# Beginner Nick12-Oct-07 10:53
C# Beginner Nick12-Oct-07 10:53 
GeneralRe: Button Questions Pin
Kristian Sixhøj12-Oct-07 10:56
Kristian Sixhøj12-Oct-07 10:56 

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.