Manipulate Data in a data set

dotnet framework


  • 1. Handling concurrency violations
    Hi I have developed the following logic to handle db concurrency violations. I just wonder if someone can tell me if it is correct or if I need a different approach.Would love to know how pros handle it. Thanks Regards Dim dc As DataColumn Dim drCache As DataRow Dim drCurrent As DataRow Try ' Attempt the update daContacts.Update(ds.Contacts) Catch Ex As DBConcurrencyException ' First - cache the row drCache = ds.Contacts.NewRow() For Each dc In ds.Contacts.Columns If Not dc.ReadOnly Then drCache(dc.ColumnName) = Ex.Row(dc.ColumnName) End If Next ' Refresh from database daContacts.Fill(ds.Contacts) ' Position to the faulted row drCurrent = ds.Contacts.Rows.Find(Ex.Row("ID")) ' Apply User Changes For Each dc In ds.Contacts.Columns If Not dc.ReadOnly Then drCurrent(dc.ColumnName) = drCache(dc.ColumnName) End If Next ' Save again daContacts.Update(ds.Contacts) End Try
  • 2. The user instance login flag is not supported on this version of S
    I copied a C# project from one machine to another both XP Pro with VS2005. Then solution compiles but when I run the app I get the error message on the first dataadapter.FILL() command: "The user instance login flag is not supported on this version of SQL Server. " SQLExpress and SQ 2000 is installed, but I am specifiing SQL Express in the connection string see below and the SQL 2000 server is not started. Do I need to uninstall the SQL 2000 server? Shouldn't this work with the SQL 2000 on the same machine? When I just remove the "User Instance =True" from the connection string I still get this message. What am I doing wrong? <connectionStrings> <add name="CMMB1.Properties.Settings.CallMasterSQLConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\CALLMaster\Data\CallMasterSQL.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings> -- Thanks Morris
  • 3. Help with multiple connector/table query
    As a newbie to ADO.NET I am struggling with the following: I have an ODBC data table that I want to use a source for updates to a SQL server table, I envisage the sql query having the following structure:- INSERT INTO SQL_TABLE FROM SELECT ODBC_TABLE WHERE ODBC_TABLE.KEY NOT IN (SELECT SQL_TABLE.KEY FROM SQL_TABLE) How do I do this in if a sql query is run against a specific connection object? Hope the above makes sense. Help greatly appreciated. Regards,
  • 4. DataColumn DataType Conversion
    I have an application that takes a DataTable full of string values and then inserts them into a SQL Table with SqlBulkCopy. I have one unresolved issue. The values in the DataTable are all strings, but the fields in the SQL Table, are not all string types. So we have the following dilemma: Converting the DataType of a DataColumn in a DataTable that is already populated is illegal. I certainly can use the Expression field of the DataColumn class and create a new DataColumn with the appropriate DataType, but I cannot leave the original column as all columns are used in SqlBulkCopy and removing the original column invalidates the expressions. And so: Is there any way to create a new DataTable, by copying the Columns that don't need conversion and the values in the Expression columns, without going value by value through the whole table?

Manipulate Data in a data set

Postby Chicagoboy27 » Sun, 27 Aug 2006 03:40:43 GMT

Sorry if this is a basic question but I was wondering how to test the
dataset information as it is being read.

ex, I have a table that contains file extentions such as .xls, .doc,
.ppt. What I want to do is test the dataset as they are being written
and if the dataset is equal to .xls i want it to be excel..

I am new to this and am able to connect to the table but I just can
seem to get a handle on how to test the current dataset record and make
any changes. any bump in the right direction would be helpful ...
thanks in advance

Re: Manipulate Data in a data set

Postby Cor Ligthert [MVP] » Sun, 27 Aug 2006 12:59:12 GMT


I get the idea that you mix up a dataset with an XML file.

A dataset is an XML file where the tags etc are used in a special way.

It has if it is not nested only elements, which are 3 deep.

There are lot of other types of XML files, by instande for Excel, For Words 

XML is however not the subject of this newsgroup, for that are probably 
better newsgroups.

I hope however that this helps a little bit.


"Chicagoboy27" < XXXX@XXXXX.COM > schreef in bericht 

Similar Threads:

1.Manipulating data between data adapters


I have two data adapters bound to two separate tables. How can I;

1. Loop through all records one by one in one of them while reading column 
values, and

2. Insert a record from data adapter A into data adapter B

via code?



2.Data Adapters, Data Sets, Data TableMappings, and XML

Here's what I'm trying to do:

1. Create a data adapter with Select and Insert commands.

2. Use DataTableMappings to map XML tags into columns in a 
data base table.

3. Create a dataset

3. Read in a schema using dataset.ReadXmLSchema

4. Read in an xml file that contains the data using 
dataset.Read XML

5. Add 3 new columns to the dataset. (These columns have 
already been mapped in step 2).

6. Put data in the 3 new columns.

7. Modify some data in the other columns using xpath 
queries to find the nodes that need changing.

8. Use datadapter.update(dataset, tablename)

Everything seems to work fine until step 8. I get all the 
data, the extra columns get added, and the data in other 
columns gets modified. When I execute step 8 I get:

Run-time exception thrown : 
System.InvalidOperationException - Cannot add or remove 
columns from the table once the DataSet is mapped to a 
loaded XML document.

Any ideas about how I can either fix this or do it another 


3.problem with data adapter and data set while inserting and retrieving data

i am using a data adapter and a dataset for filling and retrieving data
into .mdb database.
following is the code.....

for the form load event
  Dim dc(0) As DataColumn
            If OleDbConnection1.State = ConnectionState.Closed Then
                MsgBox("connection can not be established")
            End If
            DA.Fill(DataSet11, "Table1")
            cmd = New OleDbCommandBuilder(DA)
            dc(0) = DataSet11.Tables("Table1").Columns("EmpID")
            DataSet11.Tables("Table1").PrimaryKey = dc
        Catch ex As Exception
        End Try
        Delete.Enabled = False
    End Sub

for  inserting values into the DB

Private Sub Insert_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Insert.Click
        Dim dr As DataRow
        dr = DataSet11.Tables("Table1").NewRow
        dr.Item(0) = Val(TB1.Text)
        dr.Item(1) = TB2.Text
        dr.Item(2) = TB3.Text
        dr.Item(3) = Val(TB4.Text)
        dr.Item(4) = TB5.Text
        DA.Update(DataSet11, "Table1")
        MsgBox("data is saved")
        rno = 0
        call filldata()

filldata function consists of the following

 With DataSet11.Tables("Table1").Rows(rno)
         TB1.Text = Trim(.Item(0))
         TB2.Text = Trim(.Item(1))
         TB3.Text = Trim(.Item(2))
         TB5.Text = Trim(.Item(4))
         End With

the error it gives is " there is no row at
0........system.nullreference...........i checked the connection and
its working fine and also the database is getting accessed........the
error is occuring at the line " With
DataSet11.Tables("Table1").Rows(rno) " to verify the data set filling the right data table

Hi all,

I am now writing 1 stored procedure(sp) which execute 
other 2 sp, therefore result of 2 data set and 2 dataset 
tables.  But how can I ensure the right dataset filling 
the right tables so that .net crystal report can access 
the table's result to generate report.
Please help me, it drive me nearly crazy because I cannot 
generate the subreport.  Please help me.

P.S. I want 2 sp are independent for query.  But just have 
1 key of them can be joined.

Thanks and regards,

5.Serializing data set with de-normalized data

I have a DataSet where some data items are actually objecy ot type string[]. 
If I output a schema using DataSet.WriteXmlSchema() using , I get:

<xs:element name="ItemName" msdata:DataType="System.String[], mscorlib, 
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
type="xs:string" minOccurs="0" />

Accessong these items works fine in code:

string[] results = (string[])row["ItemName"];

But when I try to use the DataSet.WriteXml() method to serialize the data, 
the output does not contain the desired data:


Clearly the serializer is calling the item value's ToString() method intread 
of recognizing that it is a string array and digging deeper.  I think I 
understand why; the proper way to structure such a DataSet is to normalize 
it such that "multi-valued" items are stored in a separate table with a data 

Yet, I have to deal with the DataSet I have.  Is there any option for 
overriding how certain items are serialized and deserialized?  Or am I stuck 
with writng my own serializer from scratch? 

6. Data Sets Vs Data Readers

7. Passing parameter for Stored Procedure to Data Adapter/Data Set

8. can data be retrieved from a data set or do I need to use a da

Return to dotnet framework


Who is online

Users browsing this forum: No registered users and 88 guest