// Start a local transaction
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadCommitted);
// Assign transaction object for a pending local transaction
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')";
Console.WriteLine("Both records are written to database.");
catch (OleDbException ex)
if (myTrans.Connection != null)
Console.WriteLine("An exception of type " + ex.GetType() +
" was encountered while attempting to roll back the transaction.");
Console.WriteLine("An exception of type " + e.GetType() +
" was encountered while inserting the data.");
Console.WriteLine("Neither record was written to database.");
but i get the following exception : An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: This OleDbTransaction has completed; it is no longer usable.
I was wondering if someone could point me in the right direction for the following problem:
I created a SQL database which includes a payment system to process customer payments, when defining the Table which will hold the Payments from customers, I couldn't decide if i should create a table for Payment Types (cash, credit card, checking etc...) and add a relationship for each customer payment to the Payment Type table, or use a set of predefined characters to identify payment types (S=cash, C=credit card, H=checking etc...)
A payment type table is definitely more in compliance with the relational database modal, but on the other hand, since i will at most only have 4 or 5 payment types it will offer much better performance since there is no joins and PK/FK constraints and it will save space as well.
Yet at you end up having a performance overhead when you end up having to convert the payment type back. Plus, what happens if you add a payment type? Add a row and get the functionality for free, or change a hunk of code to handle the new Quarterly Cash payment type that your customer wants?
Stick with the normalised version - the overhead of the fk isn't that great.
Deja View - the feeling that you've seen this post before.
You have a very good point about the performance (although its not in the db its in the app which is generally cheaper)
The problem of adding a new payment type hit me as well. Initially i decided i can save a list of payment types in a configuration file and add the new one there, i figured its not that often that i will be adding a new payment type anyway. But why reinvent the wheel when i can have that list saved in the db itself.
I’m still struggling with the BindingNavigator control in Visual Studio 2005.
What I want to do is create a DataSet and populate it with data retrieved from a specific database table using a stored procedure. The code to accomplish this part is shown below.
'Connect to the database
Dim cn As SqlConnection = New SqlConnection()
cn.ConnectionString = My.Settings.DBConnectionString
'Retrieve the data using a stored procedure
Dim cd As New SqlCommand("mrmsp_ListBinding", cn)
'Declare the SQLDataAdapter and DataSet
Dim MySqlDataAdapter As New System.Data.SqlClient.SqlDataAdapter()
Dim MyDataSet As New System.Data.DataSet
'Set the database connection for MySqlDataAdapter
MySqlDataAdapter.SelectCommand = cd
'Fill the DataSet
Now I need to set the BindingNavigator's DataSource to the DataSet we created as shown below.
'Set the BindingNavigator's DataSource to the DataSet we created.
naviBindings.BindingSource.DataSource = MyDataSet
This is where I’m running into trouble. I have a form that contains four text boxes. I want to bind each of these text boxes to a different field from the DataSet I created. A simple example would be:
TextBox1 = DataSet.Field1.Value
So First Question: How do I bind specific database fields from a DataSet to a specifc control on the form using VB.NET code?
what is the solution to the timeout problem while filling some dataset using sqldataadapter.When the query tested in query analyzer generates result set after considerable time duration (like 20 seconds) .while the application doesnt stay for that long thus leaving the dataset empty .I also changed timeout value in web.config but it didnt work .