Adding a record using ADO.NEt 2.0

  • Thread starter Thread starter SK
  • Start date Start date
S

SK

Hello,
I have a Newbie question. I am using .NET 2.0 and C#.
I have a data entry screen which has about 25 fields. Excepting one
field, none of the others fields require inputs.
My question
What is the best method to insert the records to a SQL db - calling the
SQL insert i.e. "insert into...."
OR
Putting all the fields into a hashtable, and then calling a stored proc
which will take about 25 params to add a record(doesn't seem to be
good).
Is there a good way of achieving this?
Help will be highly appreciated.
Thanks
SK
 
If you want easy without a huge sacrifice, create a strongly typed dataset
on the same connection string you plan to do all of your work. Drop the
table in question on the DataSet and then use the Table adapter to do the
work.

Thte stored procedure is fine, although the hashtable implementation
requires some work unless you use a DAL library that already can match
parameters.

SQL is also fine, but parameterize the SQL rather than just concatenate a
string. Two reasons:

1. SQL Injection
2. Database query caching enabled, for performance

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 
Back
Top