Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 updating sql table

Author  Topic 

pitt1
Starting Member

16 Posts

Posted - 2006-06-18 : 08:29:46
Hi all,
first, I'm quite new to C#/asp.net/sql-server...

now, i'm writing an asp.net web application using c#,
(Visual studio 2003)
in some point i want to give the user an option
to update rows in a sql-server table,

i'm kind of don't really know what is the best way to attack this issue,
should I’ll get parameters from a box and parse them into an update query,
should I’ll right a stored procedure that gets arguments and will update the table ?
or should i do it (if possible) through a data set I’m using,
besides, is there any common/popular/build in .net way of updating a table ?


Best,
P.

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-06-18 : 11:26:36
use Stored proceedures, although there are arguments in some quarters of .net that say, parameterized queries are also safe.

For SP, just call the SP Name and pass your parameters to it and let it work 4u.
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-20 : 16:52:45
quote:
is there any common/popular/build in .net way of updating a table ?


With Asp.Net there are hundreds of ways to do something like this. What you eventually want will depend on your particular situation.

However, I must agree that using Stored procedures with the sql command object is the way to go.

JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

pitt1
Starting Member

16 Posts

Posted - 2006-06-22 : 06:20:10
finally wrote something like:

private void testing(string id, string val)
{
oleDbCommand1 = new OleDbCommand("update_qsc", oleDbConnection1);
oleDbCommand1.CommandType = CommandType.StoredProcedure;

oleDbCommand1.Parameters.Add("@id", System.Data.OleDb.OleDbType.VarChar,100); oleDbCommand1.Parameters.Add("@val", System.Data.OleDb.OleDbType.VarChar,100);

oleDbCommand1.Parameters["@id"].Value = id;
oleDbCommand1.Parameters["@val"].Value = val;

oleDbCommand1.Connection.Open();
oleDbCommand1.ExecuteNonQuery();
oleDbCommand1.Connection.Close();
}

Thanks a lot for helping...
Best,
P.
Go to Top of Page
   

- Advertisement -