473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

what is wring with this code?

Hello,
With the following I am merging two dataset and I see the result in the
datagrid but not in myTable.
Where might my problem be?

private void myMethod()
{
try
{

string strConn = ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(strConn);

SqlDataAdapter daRS = new SqlDataAdapter("SELECT * From myTable", sqlConn);
SqlCommandBuilder cbRS = new SqlCommandBuilder(daRS);
sqlConn.Open();
DataSet dsRS = new DataSet();
daRS.Fill(dsRS,"myTable");

PVS.myWS.Loader load = new PVS.myWS.Loader();
PVS.myWS.PVSTDS ds=load.getDataSet();

dsRS.Merge(ds,true);

dataGrid1.DataSource=dsRS;

daRS.Update(dsRS,"myTable");
sqlConn.Close();

catch (Exception ex)
{
throw ex;
}
}

May 17 '06 #1
2 971
You mean that the records added to the DataSet isn't added to the
database table when you call Update?

That is because the records that are merged in have the RowState set to
DataRowState.Unchanged, so the Update method ignores them.

I think that you have to add the DataRows to the DataTable (using the
Add method of the Rows property) to be able to add them to the database
table.

JIM.H. wrote:
Hello,
With the following I am merging two dataset and I see the result in the
datagrid but not in myTable.
Where might my problem be?

private void myMethod()
{
try
{

string strConn = ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(strConn);

SqlDataAdapter daRS = new SqlDataAdapter("SELECT * From myTable", sqlConn);
SqlCommandBuilder cbRS = new SqlCommandBuilder(daRS);
sqlConn.Open();
DataSet dsRS = new DataSet();
daRS.Fill(dsRS,"myTable");

PVS.myWS.Loader load = new PVS.myWS.Loader();
PVS.myWS.PVSTDS ds=load.getDataSet();

dsRS.Merge(ds,true);

dataGrid1.DataSource=dsRS;

daRS.Update(dsRS,"myTable");
sqlConn.Close();

catch (Exception ex)
{
throw ex;
}
}

May 17 '06 #2
Thank you very much for the reply.
I am quite new and I was wondering you can give me a sample of the code how
to do that?
"Göran Andersson" wrote:
You mean that the records added to the DataSet isn't added to the
database table when you call Update?

That is because the records that are merged in have the RowState set to
DataRowState.Unchanged, so the Update method ignores them.

I think that you have to add the DataRows to the DataTable (using the
Add method of the Rows property) to be able to add them to the database
table.

JIM.H. wrote:
Hello,
With the following I am merging two dataset and I see the result in the
datagrid but not in myTable.
Where might my problem be?

private void myMethod()
{
try
{

string strConn = ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(strConn);

SqlDataAdapter daRS = new SqlDataAdapter("SELECT * From myTable", sqlConn);
SqlCommandBuilder cbRS = new SqlCommandBuilder(daRS);
sqlConn.Open();
DataSet dsRS = new DataSet();
daRS.Fill(dsRS,"myTable");

PVS.myWS.Loader load = new PVS.myWS.Loader();
PVS.myWS.PVSTDS ds=load.getDataSet();

dsRS.Merge(ds,true);

dataGrid1.DataSource=dsRS;

daRS.Update(dsRS,"myTable");
sqlConn.Close();

catch (Exception ex)
{
throw ex;
}
}

May 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
2
by: Dan Allen | last post by:
have a lot of questions about ASP.Net. 1. What products do I need from Microsoft to develop and run ASP.NET As background, I currently use Visual InterDev to make ASP applications deployed on...
15
by: Don Vaillancourt | last post by:
I do a lot of hiring for my company and a lot of the people I interview say that they are experts at SQL queries, but when I give them something simple just beyond the typical SELECT type of...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
5
by: Peter | last post by:
Team VB.net, I have multiple programs that need a tool to count lines in a text files. I have been solving this problem through writing proceedures but I hate cutting and pasting code. Is...
1
by: Sean128 | last post by:
Hi, I hope someone can help me - this seems like it should be a really simple problem but I've been having trouble trying to solve it all week. I have hosted my website on a Linux server in 1...
16
by: HillBilly | last post by:
This is freaking me out. I'm using Membership and trying to determine if the database is online. The GetConnectionString( ) method returns a connection string as expected but not when used in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.