473,289 Members | 1,848 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,289 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 968
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.