ado.net

Possible to retrieve IDENTITY column value on insert using SqlCommandBuilder (without using Stored Proc)?

FYI: I am running on dotnet 3.5 SP1 I am trying to retrieve the value of an identity column into my dataset after performing an update (using a SqlDataAdapter and SqlCommandBuilder). After performing SqlDataAdapter.Update(myDataset), I want to be able to read the auto-assigned value of myDataset.tables(0).Rows(0)("ID"), but it is System...

SqlParameter Size - negative effects of setting to max size?

I have a SqlCommand that I want to call Prepare() on whose CommandType = Text (it cannot be a stored procedure). In order to do this, I need to set the Size attribute on the parameters to be non-zero otherwise an exception is thrown. Are there any negative effects from setting the Size on all parameters to the maximum possible size eve...

How Do I Profile the ADO.NET Connection Pool?

I'm profiling a ASP.NET web application. I believe it is very database connection intensive (excessive use of the ADO.NET connection pool). How to I tell w/out debugging how many times it is going to the pool and on average how many connections are available in the pool? Are there counters that will give me this info in PerfMon or some o...

Rhino Mocks: How to mock ADO.NET's DataRow?

ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks. Does anyone have any ideas how I could get around this problem? ...

Remote clients Can't open XLS file using ASP.NET/ADO

I'm trying to do the following: User goes to web page, uploads XLS file use ADO .NET to open XLS file using JET engine connection to locally uploaded file on web server This all works fine locally (my machine as the client and the web server) - and in fact is working on the customer's web server with remote clients but is not working...

Synchronize DataSet

What is the best approach to synchronizing a DataSet with data in a database? Here are the parameters: We can't simply reload the data because it's bound to a UI control which a user may have configured (it's a tree grid that they may expand/collapse) We can't use a changeflag (like a UpdatedTimeStamp) in the database because changes ...

Parameterized Sql queries

This is a nut I'm cracking these days Application I'm working on has some advanced processing towards SQL. One of the operations selects various metadata on the objects in the current context from different tables, based on the item names in the collection. For this, a range of "select...from...where...in()" is executed, and to prevent ...

Where can I find an open source C# project that uses ADO.NET?

I am trying to write a Windows Form and ASP.NET C# front-end and MSAccess backend for a pretty small database concept I have. I have written this application once before in just MSAccess but I now need the app and database to be in different places. I have now figured out (thanks to a StackOverflow user) that ADO will be a bad choice b...

C# - How can I add SqlParameters without knowing the name / type ?

I am creating a DB wrapper and am in the need of adding SQL paramters to my stament however I do not know the parameter names or type, how can this be done? I have seen many other libraries do this... I just want the order of values to be mapped to the stored procedure...I thought the following code would work: public DataTable Execu...

How can I read multiple tables into a dataset?

I have a stored procedure that returns multiple tables. How can I execute and read both tables? I have something like this: SqlConnection conn = new SqlConnection(CONNECTION_STRING); SqlCommand cmd = new SqlCommand("sp_mult_tables",conn); cmd.CommandType = CommandType.StoredProcedure); IDataReader rdr = cmd.ExecuteReader(); I'm n...

How can I force a complete load along a navigation relationship in Entity Framework?

Okay, so I'm doing my first foray into using the ADO.NET Entity Framework. My test case right now includes a SQL Server 2008 database with 2 tables, Member and Profile, with a 1:1 relationship. I then used the Entity Data Model wizard to auto-generate the EDM from the database. It generated a model with the correct association. Now I ...

.NET Table Adapters: Get vs. Fill?

I always seem to use Get when working with data (strongly typed or otherwise) from the database and I have never really needed to use Fill although I just as easily could use Fill instead of get when pulling out and updating data. Can anyone provide guidance as to the implications and gotchas of each method? In what situations is it p...

XML DOM vs ADO DataSet

I have the option of storing data in memory either as an XML document or multi-table ADO dataset. The web page utilizing this object will be selectively retrieving data items based on keys. Does either of these objects have a clear performance advantage over the other? ...

Ado.net Getting the schema for a table

Given an SQLConnection object how can you get a schema for a single table? I was trying this the other day and I seemed to be able to get the schema from a DataSet which I'd gotten from running a query, but all the schema info I could get from the connection seemed to be related to what tables were available and not the actual details o...

oledb/ado.net: Get the command's text, with all parameters replaced

Is it possible to get the text of an OleDbCommand with all parameters replaced with their values? E.g. in the code below I'm looking for a way to get the query text SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world' after I finished assigning the parameters. var query = "SELECT * FROM my_table WHERE c1 = ? and c2 = ?"; var c...

Adding dummy Column to strongly typed dataset

I am writing a site that uses strongly typed datasets. The DBA who created the table made gave a column a value that represents a negative. The column is 'Do_Not_Estimate_Flag' where the column can contain 'T' or 'F'. I can't change the underlying table or the logic that fills it. What I want to do is to add a 'ESTIMATION_ALLOWED' colu...

Updateable (and persistable) dataset based on a join - possible with ADO.Net???

So lets say I have a dataset based on: SELECT TopicLink.*, Topic.Name AS FromTopicName, Topic_1.Name AS ToTopicName FROM TopicLink INNER JOIN Topic ON TopicLink.FromTopicId = Topic.TopicId INNER JOIN Topic AS Topic_1 ON TopicLink.ToTopicId = Topic_1.TopicId With old school ADO, u...

dlinq versus ADO.NET Entity Framework

I am about to finalize the design of my webapplication, i am building it as an n-tier architecture and i am posed with the question of using DLinq vs EFM. I would appreciate if someone could give me some expert advice on it. ...

How to get an image stored as an oracle blob into an Image object

I am trying to retrieve an image stored in an oracle blob and place it in a new System.Drawing.Image instance. I know I can write the stream to a temp.bmp file on the disk and read it from there but thats just not l33t enough for me. How do I convert the blob object directly to an image? ...

C# Retrieving correct DbConnection object by connection string

I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string. Is there any inbuilt functionality to do this, or any 3rd party libraries to assist. We are not necessarily building this connection string, so we cann...