dbTalk Databases Forums  

VB 2005 Insert records into multiple tables

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss VB 2005 Insert records into multiple tables in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AnikSol
 
Posts: n/a

Default VB 2005 Insert records into multiple tables - 10-29-2006 , 01:15 AM






Hi All,

Not sure if this is the right forum to post this!
VB 2005 Prof, SQL server 2005, Windows application

Scenario: In a winform application, using SQL server authentication method
(not windows authentication), we have a text/binary file containing multiple
SQL statements (insert,update,delete commands) for multiple tables.
From the Winform , we need to create a process wherein we process this file
and update the database.
In case of a failure to process any sql statement in the middle of this file
(for whatsoever may be the reason , possibility is remote but should not be
excluded), then all the transaction need to be rolled back - meaning the
database state should be same as before we started the processing of this
file.

Query: What is the best method to carryout this functionality without using
DTS. Ofcourse, this process should be executed from a winform and from a
client machine.

Thanks.





Reply With Quote
  #2  
Old   
Arnie Rowland
 
Posts: n/a

Default Re: VB 2005 Insert records into multiple tables - 10-29-2006 , 09:34 AM






In the input file, start a TRANSACTION before the current SQL Statements,
test each statement for success/failure, and either ROLLBACK abort further
processing, or at the end, COMMIT as appropriate.

However, you are opening your server to major security risks.

What is the nature of the input file?
Is it being created by the user?
Created by the application?
Or is it static?
Could it be transformed into a stored procedure?

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


"AnikSol" <anisol (AT) community (DOT) nospam> wrote

Quote:
Hi All,

Not sure if this is the right forum to post this!
VB 2005 Prof, SQL server 2005, Windows application

Scenario: In a winform application, using SQL server authentication method
(not windows authentication), we have a text/binary file containing
multiple
SQL statements (insert,update,delete commands) for multiple tables.
From the Winform , we need to create a process wherein we process this
file
and update the database.
In case of a failure to process any sql statement in the middle of this
file
(for whatsoever may be the reason , possibility is remote but should not
be
excluded), then all the transaction need to be rolled back - meaning the
database state should be same as before we started the processing of this
file.

Query: What is the best method to carryout this functionality without
using
DTS. Ofcourse, this process should be executed from a winform and from
a
client machine.

Thanks.







Reply With Quote
  #3  
Old   
AnikSol
 
Posts: n/a

Default Re: VB 2005 Insert records into multiple tables - 10-31-2006 , 08:48 AM



Arnie,

Thanks.

Maybe I wan't clear in asking my query.

What I wanted to know was which method would be more appropriate -
- using BCP (since the file only contains valid SQL commands) - what happens
in case if there is a failure after processing of few records?
- use transaction scope (but somehow I am unable to do multiple commands in
the scope)
- use Adon.net transaction ( transaction.begin , commit, etc) (this is the
way you have recommended , but with a caution)

The file is in fact generated by an application so the chances of having an
improper sql command string is quite remote. It is definitely not static.
There would be one file to be "imported " daily.

thanks.


"Arnie Rowland" <arnie (AT) 1568 (DOT) com> wrote

Quote:
In the input file, start a TRANSACTION before the current SQL Statements,
test each statement for success/failure, and either ROLLBACK abort further
processing, or at the end, COMMIT as appropriate.

However, you are opening your server to major security risks.

What is the nature of the input file?
Is it being created by the user?
Created by the application?
Or is it static?
Could it be transformed into a stored procedure?

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to
the top yourself.
- H. Norman Schwarzkopf


"AnikSol" <anisol (AT) community (DOT) nospam> wrote in message
news:uobiTGy%23GHA.4356 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
Hi All,

Not sure if this is the right forum to post this!
VB 2005 Prof, SQL server 2005, Windows application

Scenario: In a winform application, using SQL server authentication
method
(not windows authentication), we have a text/binary file containing
multiple
SQL statements (insert,update,delete commands) for multiple tables.
From the Winform , we need to create a process wherein we process this
file
and update the database.
In case of a failure to process any sql statement in the middle of this
file
(for whatsoever may be the reason , possibility is remote but should not
be
excluded), then all the transaction need to be rolled back - meaning the
database state should be same as before we started the processing of this
file.

Query: What is the best method to carryout this functionality without
using
DTS. Ofcourse, this process should be executed from a winform and
from a
client machine.

Thanks.









Reply With Quote
  #4  
Old   
Wei Lu [MSFT]
 
Posts: n/a

Default Re: VB 2005 Insert records into multiple tables - 11-01-2006 , 01:55 AM



Hello Anik,

According to your situation, I think you may try to consider to use the
ADO.NET transcation so that you could control the transaction in your
application.

Sincerely,

Wei Lu

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Reply With Quote
  #5  
Old   
Wei Lu [MSFT]
 
Posts: n/a

Default Re: VB 2005 Insert records into multiple tables - 11-03-2006 , 03:01 AM



Hi ,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #6  
Old   
AnikSol
 
Posts: n/a

Default Re: VB 2005 Insert records into multiple tables - 11-06-2006 , 09:21 AM



Wei,

Thanks. We have implemented the ado.net transactions.

regards

"Wei Lu [MSFT]" <weilu (AT) online (DOT) microsoft.com> wrote

Quote:
Hi ,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.