ado.net

Ado.net performance:What does SNIReadSync do?

We have a query that takes 2 seconds to run in Sql Server Management Studio but it takes 13 seconds to be shown on a client screen. I used dotTrace to profile my source code and noticed there is this SNIReadSync method (part of ADO.net assemblies)that takes a lot of time to do its job(9 seconds).I ran my source over server so I could omi...

Is there a code-generator to create DataTable definition block from Excel Work sheet?

Hi, Basically the thing I want to achieve is to have a data-table that I want to use in my unit tests. And when I run my unit tests, I do not want to read any excel file into a data-table -or any call to Db-. So, I would like to have method that returns a data-table with the values that I can use in my test. Is there already any writ...

Paste table name as parameter

I want to paste table name as function parameter and function need to return DataSet, this is the my code for that: Public Function GetTTabele(ByVal tableName As String) As DataSet Dim DAT As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM tableName", nwindConn) Dim DAT As DataSet = New DataSet() DAT.Missin...

Iterating strongly typed DataSets

I basically need to be able to iterate through tables to extract, transform and load data into typed datasets. Based on the table name from a list I need to construct the *TableName*TableAdapter.GetData() and then *TableName*TableAdapter.Update(). The only thing I can think of (beside writing this code for each table) is using reflect...

add a connection to database not working, asp.net to mdf

i am adding a connection in asp.net using visual web developer to sql server database file, it's an MDF file. when i click test connection i get this: can someone please help me set up this connection ...

DataColumn.AutoIncrementSeed = -1

What does it means if AutoIncrementSeed property has value -1 ? ...

ADO.NET - Bad Practice?

I was reading an article in MSDN several months ago and have recently started using the following snippet to execute ADO.NET code, but I get the feeling it could be bad. Am I over reacting or is it perfectly acceptable? private void Execute(Action<SqlConnection> action) { SqlConnection conn = null; try { conn = new SqlCo...

WCF. to send data through service and client

I have a service. This service get data from SQL Server. What the best way to send information to client? Should I use ADO.NET or Entity Framework? ...

Release SqlConnection without "finally"

I got a task to maintain a c# project, I found some code like this: try{ conn.Open(); ... conn.Close(); }catch(Exception e){ conn.Close(); } I know that the usual way to close SqlConnection is try-catch-finally or "using" keyword, but I found that I can't prove the code above is wrong, I can't find any situatio...

Difference of ADO.Net's Transaction connecting to SQL Server 2000 and SQL Server 2008

hi, I have some C#/ado.net code which acts differently with SQL Server 2000 and SQL Server 2008. SqlConnection con = new SqlConnection("connecstionstring"); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "MySp"; con.Open(); SqlTransaction trans = con.BeginTransaction(); cmd.Transac...

why would GetValues take an object array as input rather than return a new array

The SqlDataReader class offers a method called GetValues. What I find curious about this method is that it takes an object[] as input and returns an int of the number of values copied into the array. Any idea why the method was designed that way, rather than returning a new Array? ...

Trigger not executing when a Batch Update runs.

I am using VB.Net 2008 and ADO.Net to do a Batch Update to our Oracle database. The updates are working, but there is a trigger on the table before the row is updated to enforce a member's termination termination date. So if I was trying to set the termination date (via the batch update) to 31-Jan-2010 but the member had a claim that w...

Error Using ADO.NET Entity Framework

I want to convert a list to EntityCollection. List<T> x = methodcall(); EntityCOllection<T> y = new EntityCollection<T>(); foreach(T t in x) y.Add(t); I get this error. The object could not be added to the EntityCollection or EntityReference. An object that is attached to an ObjectContext cannot be added to an EntityCol...

Get the details of the current row when using a typed dataset/binding source in a winforms application

I want to delete the current row in a grid only if a specific value exists in a column. How can I get the details for the current row? ...

ADO.NET DataSet with Parent-Child tables foreign key error

I have a parent table and child table and I would want to insert into them using a dataset/datatable/dataadapter combination. Inside the SQL Server database the parent table is declared with a primary key, and the child table with a foreign key -- the primary of the parent. One entry in the parent table could potentially have 0->n entrie...

how to query (oracle) database table structure in C# / (ADO?).NET 2.0

I want to get table metadata for all table columns. Like type string(varchar2)/int/float/datetime and length for strings etc. Cheers! -Matti ...

is it possible to lock oracle 10g database table with ADO.NET?

I have a table that contains a maximum value that needs to be get and set by multiple programs. How can I lock the table for a while when old value is got and new is updated in C#? In other words: string sql = "lock table MaxValueTable in exclusive mode"; using (DbCommand cmd = cnctn.CreateCommand()) { cmd.CommandText = sql; ...

how to implement oracle -> oracle conversion/refresher program in C# / ADO.NET 2.0

When program runs 1st time it just gets some fields from a source database table say: SELECT NUMBER, COLOR, USETYPE, ROOFMATERIALCODE FROM HOUSE; //number is uniq key it does some in-memory processing say converting USETYPE and ROOFMATERIAL to destination database format (by using cross ref table). Then program inserts ALL THE ROWS...

TransactionScope and Stored Procedure?

I have two PL/SQL Stored procedure each handling its own Transaction (Begin/Commit and Rollback in case of error). From .Net code I Call these two SP as shown below. using (TransactionScope ts = new TransactionScope()) { CallSP1(); CallSP2(). ts.SetComplete(); } If my Call to SP2 fails will i...

How does Connection pool work in Ado.net?

I am connecting to a legacy rdbms system using System.Data.OdbcClient. I would like to know if the connection pool is supported by the legacy rdbms system? Suppose I use Connection as shown below using (OdbcConnection con = new OdbcConnection("ConnStr")) { con.Open(); //perform db operation } Does it establishes a connection...