Part of some of my classes (hope it'll give you a clue
where to go):
public static void UpdateDataTable (DataTable
dataTable,SqlCo nnection conn,string sql,params object[]
parameters)
{
SqlCommand comm = PrepareCommand
(conn,sql,param eters);
SqlDataAdapter da = new SqlDataAdapter( comm);
DataSet ds = new DataSet();
da.Fill(ds);
SqlCommandBuild er cb = new SqlCommandBuild er(da);
UpdateDataTable (ds.Tables[0],dataTable);
da.Update(ds.Ta bles[0]);
}
public static SqlCommand PrepareCommand( SqlConnection
connection,stri ng sql, params object[] parameters)
{
SqlCommand comm = PrepareCommand( sql,parameters) ;
if( connection.Stat e == ConnectionState .Closed )
connection.Open ();
comm.Connection = connection;
return comm;
}
public static SqlCommand PrepareCommand( string sql,params
object[] parameters)
{
SqlCommand comm = new SqlCommand(sql) ;
Regex re = new Regex
(@"(@\w+)",Rege xOptions.ECMASc ript);
MatchCollection mParams = re.Matches(sql) ;
for( int g=0; g < mParams.Count && g <
parameters.Leng th; g++ )
comm.Parameters .Add(mParams
[g].Value,paramete rs[g]==null?DBNull.V alue:parameters[g]);
return comm;
}
sql string is a select statement used to populate dataset
which gives that Table.
Regards.
-----Original Message-----
Hi Team,
I want to use DataSet in my ASP.Net application
extensively.
Scenario is,
I am showing Data Set in one of my ASP.Net Page and
changing row & columnvalues thru Page. After that I want to send this changed
DataSet to Serverside and want to use "DataAdapter.Up date" to commit the
change intoDatabase.
Is this possible ?
Please let me know with code.
Thanks in advance.
-Vinod
.