473,399 Members | 2,278 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,399 software developers and data experts.

Typed dataset is not really committing data to database

Hello, I'm a newbee to .net. I've created a typed dataset in VS. When I
insert a row, it shows that it's there but in fact the row is not committed
to the database. When I restart my app, the new row is gone. Could someone
help me out on this?

Here my proc that does the insert:
(note: i've created a new part (partial class) to the tableadapter so that
it's possible to set the transaction to the command that does the insert)

any help will be appreciated

private void btnMaakTestData_Click(object sender, EventArgs e)
{
int lAantal = int.Parse(cmbAantal.SelectedItem.ToString());

ProspectsTableAdapters.prospectTableAdapter lTA = new
prospectTableAdapter();

Properties.Settings settings = new Settings();
SqlConnection conn = new
SqlConnection(settings.CRMManagerConnectionString) ;
conn.Open();
lTA.Connection = conn;
long lMaxID = (long)lTA.MaxProspectId();
SqlTransaction trans =
conn.BeginTransaction(System.Data.IsolationLevel.R eadCommitted);
lTA.Transaction = trans; // sets insertcommand.transaction
try
{
for (int i = 1; i <= lAantal; i++)
{
long lID = lMaxID + i;
lTA.Insert(
lID,
"Prospect " + lID.ToString(),
"T.T.",
"van den",
"drs",
null,
"Van Benthemlaan",
"12",
"1212 EB",
"Hilversum",
null,
"Nederland",
DateTime.Now,
DateTime.Now);
}
}
catch (Exception ex)
{
trans.Rollback();
throw ex;
}
trans.Commit();
MessageBox.Show("Klaar");
}
Dec 6 '07 #1
1 2886
Well, the code looks ok (I haven't tried to compile it, and can't, since
it's not a complete example, and I don't have an underlying data source).

Have you placed a breakpoint on the exception? I ask because the event
handlers for controls will swallow exceptions, and you won't see them. So
it's very possible an exception is occuring and you aren't seeing it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"J. Ouwehand" <ja**********@gmail.comwrote in message
news:Og****************@TK2MSFTNGP04.phx.gbl...
Hello, I'm a newbee to .net. I've created a typed dataset in VS. When I
insert a row, it shows that it's there but in fact the row is not
committed to the database. When I restart my app, the new row is gone.
Could someone help me out on this?

Here my proc that does the insert:
(note: i've created a new part (partial class) to the tableadapter so that
it's possible to set the transaction to the command that does the insert)

any help will be appreciated

private void btnMaakTestData_Click(object sender, EventArgs e)
{
int lAantal = int.Parse(cmbAantal.SelectedItem.ToString());

ProspectsTableAdapters.prospectTableAdapter lTA = new
prospectTableAdapter();

Properties.Settings settings = new Settings();
SqlConnection conn = new
SqlConnection(settings.CRMManagerConnectionString) ;
conn.Open();
lTA.Connection = conn;
long lMaxID = (long)lTA.MaxProspectId();
SqlTransaction trans =
conn.BeginTransaction(System.Data.IsolationLevel.R eadCommitted);
lTA.Transaction = trans; // sets insertcommand.transaction
try
{
for (int i = 1; i <= lAantal; i++)
{
long lID = lMaxID + i;
lTA.Insert(
lID,
"Prospect " + lID.ToString(),
"T.T.",
"van den",
"drs",
null,
"Van Benthemlaan",
"12",
"1212 EB",
"Hilversum",
null,
"Nederland",
DateTime.Now,
DateTime.Now);
}
}
catch (Exception ex)
{
trans.Rollback();
throw ex;
}
trans.Commit();
MessageBox.Show("Klaar");
}

Dec 6 '07 #2

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

Similar topics

0
by: Natehop | last post by:
I've been attempting to design an n-tiered framework leveraging .NET's strongly typed Dataset. My Framework will serve as the foundation to several client apps from Windows applications to web...
2
by: BeanTownBizTalkGuru | last post by:
Trying to get some feedback. Here's the scenerio. We are processing XML data which we generated a typed dataset to represent the XML document being processed. After procesing is complete we...
1
by: HardBap | last post by:
I've created a strongly typed DataSet (Customers.xsd) using the xsd.exe tool. I want to be able to access fields using ds.Customer.CompanyName. The problem is when I return this DataSet from a...
5
by: John | last post by:
Hi, I am developing a windows app using C# 2005. This app uses SQL Server or Oracle database depending on the what the user is using. Can I create one typed dataset and use it for SQL Server and...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
1
by: Chris | last post by:
Are there any performance issues with typed datasets in a fairly high performance system?
4
by: newtonwong | last post by:
I have a web reference WSDL, but it doesn't really create an XSD. I'm trying to generate datasets from the WSDL file but not sure how to do so. I successfully created the proxy class, but the...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
7
by: =?Utf-8?B?TWF4R3J1dmVu?= | last post by:
I have a DLL that implements the Business and Data Layers for a number of different websites. That DLL uses a Strongly Typed DataSet to interface to the Data Source which is SQL Server. There...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.