insert record

N

NuB

I have an app that inserts records into a SQL db, I have a file that I'm
reading to get the data out of, aka 'records', how can I determine of the
record has been inserted into the database so i can log that?
 
N

Nicholas Paldino [.NET/C# MVP]

NuB,

Well, do the records have some sort of unique identifier for them (a
primary key, or combination of fields that indicates that it is unique)? If
so, then you can select the record from the table beforehand. If that
record exists already, then you can log (to wherever you log to) that fact
and not bother inserting the record.

Hope this helps.
 
N

NuB

No, i'm just inserting new records from a text file every time the app runs.
So if the insert piece was successfull or not i need to some how get that
value and write it out to a log file.

Nicholas Paldino said:
NuB,

Well, do the records have some sort of unique identifier for them (a
primary key, or combination of fields that indicates that it is unique)?
If so, then you can select the record from the table beforehand. If that
record exists already, then you can log (to wherever you log to) that fact
and not bother inserting the record.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

NuB said:
I have an app that inserts records into a SQL db, I have a file that I'm
reading to get the data out of, aka 'records', how can I determine of the
record has been inserted into the database so i can log that?
 
N

Nicholas Paldino [.NET/C# MVP]

NuB,

Well, if you execute your command or your data adapter (whichever you
are using to insert the record) and it executes without exception, then I
would say it succeeded. Also, the command object should be able to tell you
how many records were affected by the statement you executed.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

NuB said:
No, i'm just inserting new records from a text file every time the app
runs. So if the insert piece was successfull or not i need to some how get
that value and write it out to a log file.

Nicholas Paldino said:
NuB,

Well, do the records have some sort of unique identifier for them (a
primary key, or combination of fields that indicates that it is unique)?
If so, then you can select the record from the table beforehand. If that
record exists already, then you can log (to wherever you log to) that
fact and not bother inserting the record.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

NuB said:
I have an app that inserts records into a SQL db, I have a file that I'm
reading to get the data out of, aka 'records', how can I determine of the
record has been inserted into the database so i can log that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top