HighTechTalks DotNet Forums  

what's the best approach to follow for sql execute

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss what's the best approach to follow for sql execute in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ganesh
 
Posts: n/a

Default what's the best approach to follow for sql execute - 07-29-2007 , 07:31 AM






Hi There,

What's the better way to follow when we use sql
string sql = "Inset into table(f1,f2) values (@f1, @f2)";

then add and passing parameters or in the first place itselef assign the
values to the string
string sql = "Inset into table(f1,f2) values (" + tbName.text + ", " +
tbCity.Text +");";

Thanks

Ganesh






Reply With Quote
  #2  
Old   
Jesse Houwing
 
Posts: n/a

Default Re: what's the best approach to follow for sql execute - 07-29-2007 , 07:45 AM






* Ganesh wrote, On 29-7-2007 13:31:
Quote:
Hi There,

What's the better way to follow when we use sql
string sql = "Inset into table(f1,f2) values (@f1, @f2)";

then add and passing parameters or in the first place itselef assign the
values to the string
string sql = "Inset into table(f1,f2) values (" + tbName.text + ", " +
tbCity.Text +");";

add and passing parameters is the only way to go. You'll be vulnerable
to all kinds of security issues otherwise. (read up on SQL Injection).

Jesse


Reply With Quote
  #3  
Old   
William Vaughn
 
Posts: n/a

Default Re: what's the best approach to follow for sql execute - 07-30-2007 , 12:05 PM



The best approach is to use parameters--unless you're adding a lot of rows.
In this case SqlBulkCopy is far better.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Ganesh" <gsganesh (AT) yahoo (DOT) com> wrote

Quote:
Hi There,

What's the better way to follow when we use sql
string sql = "Inset into table(f1,f2) values (@f1, @f2)";

then add and passing parameters or in the first place itselef assign the
values to the string
string sql = "Inset into table(f1,f2) values (" + tbName.text + ", " +
tbCity.Text +");";

Thanks

Ganesh







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.