Dataset Updation

V

Vinod I

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 & column
values thru Page. After that I want to send this changed DataSet to Server
side and want to use "DataAdapter.Update" to commit the change into
Database.

Is this possible ?

Please let me know with code.

Thanks in advance.

-Vinod
 
K

Kikoz

Part of some of my classes (hope it'll give you a clue
where to go):

public static void UpdateDataTable(DataTable
dataTable,SqlConnection conn,string sql,params object[]
parameters)
{
SqlCommand comm = PrepareCommand
(conn,sql,parameters);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
da.Fill(ds);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
UpdateDataTable(ds.Tables[0],dataTable);
da.Update(ds.Tables[0]);
}
public static SqlCommand PrepareCommand(SqlConnection
connection,string sql, params object[] parameters)
{
SqlCommand comm = PrepareCommand(sql,parameters);
if( connection.State == 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+)",RegexOptions.ECMAScript);
MatchCollection mParams = re.Matches(sql);
for( int g=0; g < mParams.Count && g <
parameters.Length; g++ )
comm.Parameters.Add(mParams
[g].Value,parameters[g]==null?DBNull.Value:parameters[g]);
return comm;
}


sql string is a select statement used to populate dataset
which gives that Table.

Regards.
 
V

Vinod I

Hi Kikoz,

Thanks for the reply.

But I was looking for something else,

I repeat, I have a Dataset "DS1" in my ASP.Net page. Now I want to submit
back this Dataset to the Datalayer at Server side and Commit the Changes.
How I will make the dataadapter and attach to the dataset in this case as I
don't have the dataadapter which created to populate the dataset.

In windows applications, we used to send back the Dataset along with
Dataadapeter. How to do it in ASP.Net ?

If there is any alternative suggestions, let me know.

Thanks,

-Vinod




Kikoz said:
Part of some of my classes (hope it'll give you a clue
where to go):

public static void UpdateDataTable(DataTable
dataTable,SqlConnection conn,string sql,params object[]
parameters)
{
SqlCommand comm = PrepareCommand
(conn,sql,parameters);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
da.Fill(ds);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
UpdateDataTable(ds.Tables[0],dataTable);
da.Update(ds.Tables[0]);
}
public static SqlCommand PrepareCommand(SqlConnection
connection,string sql, params object[] parameters)
{
SqlCommand comm = PrepareCommand(sql,parameters);
if( connection.State == 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+)",RegexOptions.ECMAScript);
MatchCollection mParams = re.Matches(sql);
for( int g=0; g < mParams.Count && g <
parameters.Length; g++ )
comm.Parameters.Add(mParams
[g].Value,parameters[g]==null?DBNull.Value: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 & column
values thru Page. After that I want to send this changed DataSet to Server
side and want to use "DataAdapter.Update" to commit the change into
Database.

Is this possible ?

Please let me know with code.

Thanks in advance.

-Vinod


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top