| | |
updating database from dataset
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Dec 2007
Posts: 205
Reputation:
Solved Threads: 11
How do i update a database from dataset.
is not working
ASP.NET Syntax (Toggle Plain Text)
SqlDataAdapter.Update()
Last edited by carobee; Feb 6th, 2009 at 12:49 am.
•
•
Join Date: Dec 2008
Posts: 104
Reputation:
Solved Threads: 18
Try using the SqlCommandBuilder Class like this
ASP.NET Syntax (Toggle Plain Text)
SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter); mySqlDataAdapter.Update(myDataSet, "myTableName");
•
•
Join Date: Dec 2007
Posts: 205
Reputation:
Solved Threads: 11
Tried that but its not working. Do i have to set the update,delete and insert command?
•
•
•
•
Try using the SqlCommandBuilder Class like this
ASP.NET Syntax (Toggle Plain Text)
SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter); mySqlDataAdapter.Update(myDataSet, "myTableName");
•
•
Join Date: Dec 2007
Posts: 205
Reputation:
Solved Threads: 11
Here is the code
ASP.NET Syntax (Toggle Plain Text)
SqlDataAdapter da = new SqlDataAdapter("select * from mytable",strCon); DataSet ds = new DataSet(); da.Fill(ds); GridView2.DataSource = ds; GridView2.DataBind(); SqlCommandBuilder m_cd = new SqlCommandBuilder(da); string UpdateCommand = m_cd.GetUpdateCommand().CommandText; da.Update(ds, "mytable");
Last edited by carobee; Feb 6th, 2009 at 3:11 am.
•
•
Join Date: Dec 2008
Posts: 104
Reputation:
Solved Threads: 18
Try this:
ASP.NET Syntax (Toggle Plain Text)
SqlDataAdapter da = new SqlDataAdapter("select * from mytable",strCon); SqlCommandBuilder m_cd = new SqlCommandBuilder(da); da.MissingSchemaAction = MissingSchemaAction.AddWithKey; DataSet ds = new DataSet(); da.Fill(ds); GridView2.DataSource = ds; GridView2.DataBind(); string UpdateCommand = m_cd.GetUpdateCommand().CommandText; da.Update(ds, "mytable");
•
•
Join Date: Dec 2007
Posts: 205
Reputation:
Solved Threads: 11
Throwing an error as
ASP.NET Syntax (Toggle Plain Text)
Update unable to find TableMapping['mytable'] or DataTable 'mytable'
•
•
•
•
Try this:
ASP.NET Syntax (Toggle Plain Text)
SqlDataAdapter da = new SqlDataAdapter("select * from mytable",strCon); SqlCommandBuilder m_cd = new SqlCommandBuilder(da); da.MissingSchemaAction = MissingSchemaAction.AddWithKey; DataSet ds = new DataSet(); da.Fill(ds); GridView2.DataSource = ds; GridView2.DataBind(); string UpdateCommand = m_cd.GetUpdateCommand().CommandText; da.Update(ds, "mytable");
•
•
Join Date: Dec 2007
Posts: 205
Reputation:
Solved Threads: 11
i had replaced it with my table name.Still it was showing that error. while changing it to
as you suggested, no updation was done on the table
ASP.NET Syntax (Toggle Plain Text)
da.Update(ds.Tables[0]);
![]() |
Similar Threads
- Problem updating Database using typed dataset (C#)
- Database updating from changed dataset (VB.NET)
- Problem with updating database after delete or edit (VB.NET)
- deleted rows not updating (C#)
- Beginner: how to add new record into database??? (VB.NET)
- Updating database with related tables and queries?? (VB.NET)
- Error connecting to database (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: how can i populate my gridview with dropdown
- Next Thread: Lock Window
Views: 1366 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# cac chat checkbox child class compatible complex content contenttype control countryselector courier database datagrid datagridview datalist deployment development dgv dialog dropdown dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv folder form gridview gudi identity iis image javascript languages list maps menu mobile mssql nameisnotdeclared novell opera order problem profile ratings redirect refer registration relationaldatabases response.redirect rows search security select serializesmo.table sessionvariables silverlight smoobjects software sql ssl tracking treeview typeof validatedate validation vb vb.net vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xsl





