Advertisement

12.11.2007 at 05:54PM PST, ID: 23017376
[x]
Attachment Details

Dataset Update to Database with OLEDBDataAdapter??

Asked by Kelvin81 in Programming for ASP.NET, Sybase Database, ADO.Net Class Library

Tags: dataset, oledbdataadapter, update, database

Hi,

I've been working for several months to get data back into a Sybase database.  I have gotten to the point where I can retrieve data into a grid view, then edit the data in the gridview, and hit the update button and update the gridview and the dataset.

I am stuck on trying to push the dataset changes back into the database.  I have tried several different ways, and a number of them don't give me errors, but don't make the changes either.  I am guessing it is because I don't have the proper .UpdateCommand in my DataAdapter?

Below is the latest incarnation of the code that I have been trying to use.


As you can see below, I have tried several different ways, and there are still remnants from other attempts in there.  Most of the online references that I found have ObjectDataAdapters, but that approach didn't seem to work for me, and anything thats working with a dataset directly only uses a SQL adapter with a SQLServer DB.  

Can someone help me make this work?  Am I going about this the wrong way (I would rather not have anything strongly typed to give it the scalability and flexibility that I'm looking for)?


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
if (ViewState["ds"] != null)
            {
                DataSet ds = (DataSet)ViewState["ds"];
                string strConn = "Provider=Sybase.ASEOLEDBProvider.2;Data Source=DSRFCLDD02;Initial Catalog=SDAPSLDN5;Password=xxxx;User ID=xxxxxxx";
                OleDbConnection conn = new OleDbConnection(strConn);
                OleDbDataAdapter da = new OleDbDataAdapter
                        ("Select top 50 UserID, UserName, FullName, TraderID from users", strConn);
               da.UpdateCommand = new OleDbCommand("UPDATE users SET" +
                            "UserID = ?, UserName = ?, FullName = ?, TraderID = ?", conn );
 
                da.UpdateCommand.Parameters.Add("UserID", OleDbType.LongVarBinary);
                da.UpdateCommand.Parameters.Add("UserName", OleDbType.VarChar);
                da.UpdateCommand.Parameters.Add("FullName", OleDbType.VarChar);
                da.UpdateCommand.Parameters.Add("TraderID", OleDbType.LongVarBinary);
 
                DataTable dt = ds.Tables[0].GetChanges(DataRowState.Modified);
                try
                {
 
                    foreach (DataRow dataRow in ds.Tables[0].Rows)
                    {
                        dt.ImportRow(dataRow);
                        dt.AcceptChanges();
                    }
                   // ds.AcceptChanges();
                    da.Update(dt);
                }
                catch (Exception err) { lblErrLabel.Text = err.ToString(); }
            }
[+][-]12.11.2007 at 10:27PM PST, ID: 20455466

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 10:46PM PST, ID: 20455519

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 10:50PM PST, ID: 20455532

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:06PM PST, ID: 20455575

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:11PM PST, ID: 20455585

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:15PM PST, ID: 20455591

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:20PM PST, ID: 20455607

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:23PM PST, ID: 20455615

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:26PM PST, ID: 20455618

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:41PM PST, ID: 20455644

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:43PM PST, ID: 20455648

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.11.2007 at 11:56PM PST, ID: 20455688

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:00AM PST, ID: 20455696

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:06AM PST, ID: 20455721

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:10AM PST, ID: 20455731

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:15AM PST, ID: 20455747

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:18AM PST, ID: 20455753

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:20AM PST, ID: 20455756

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:32AM PST, ID: 20455782

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 12:58AM PST, ID: 20455875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 01:03AM PST, ID: 20455887

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 02:49AM PST, ID: 20456181

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 02:52AM PST, ID: 20456193

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 03:13AM PST, ID: 20456280

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 03:14AM PST, ID: 20456287

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 04:58AM PST, ID: 20456681

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 05:56PM PST, ID: 20461799

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 08:35PM PST, ID: 20462387

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 11:11PM PST, ID: 20462841

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.12.2007 at 11:14PM PST, ID: 20462845

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Sybase Database, ADO.Net Class Library
Tags: dataset, oledbdataadapter, update, database
Sign Up Now!
Solution Provided By: vbturbo
Participating Experts: 4
Solution Grade: A
 
 
[+][-]12.13.2007 at 05:58PM PST, ID: 20469245

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.14.2007 at 08:38AM PST, ID: 20472604

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.15.2007 at 05:39PM PST, ID: 20479410

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 07:52PM PST, ID: 20912677

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628