ado.net

Are the only changes in ADO.Net for .Net 4 in Entity Framework?

It seems from the MSDN overview that the only change to ADO.Net in .Net 4 is the addition of Entity Framework. I'm working on refactoring some legacy database access to use ADO.Net and one of the things I'd like to document as project issues is any benefit from moving to .Net 4 from the .Net 3.5sp1 we're currently targeting (we have a W...

OOPS and ADO.Net

Hi, I am building an bugtracking application where I am thinkining of taking maximum possible benefits of OOPS starting from my presentation layer to my data access layer. The architecture will be as usual 3-tier but I want to use Design Patterns or simply OOPS to create connection pull out data or something like that. ...

when i merge a data table with a typed dataset, one single field on a single row is DBNull sometimes

Hi everybody, I have a strange problem sometimes when I try to merge a data table with a typed dataset my data table is filled in with a stored procedure and when I checked the content of this table it is ok, everything is in there straight after I merge it with my core typed dataset like this : MyTypedDataSet.TheTable.Clear(); MyTyp...

Is it possible with dynamic TSQL query ?

I have very long select query which i need to filter based on some params, i'm trying to avoid having different stored procedures or if statements inside of single stored procedure by using partly dynamic TSQL... I will avoid long select just for example sake select a from b where c=@c or d=@d @c and @d are filter params, only one ca...

Cache Function Import :: ADO.NET Entity Model

Hi, I have imported an SQL Stored Procedure using the built-in 'Function Import' of Visual Studio 2010. I was wondering if there is a built-in, or custom, way to cache the results, just like you can cache a Control, or a Page, or even just a string; using the built-in Cache in .NET If this needs more clarification, just let me know. ...

How to prevent ADO.NET from altering double values when it reads from Excel files

I have the following rows in my Excel input file: Column1 Column2 0-5 3.040 6 2.957 7 2.876 and the following code which uses ADO.NET to read it: string fileName = "input.xls"; var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8...

Can the Sequence of RecordSets in a Multiple RecordSet ADO.Net resultset be determined, controlled?

I am using code similar to this Support / KB article to return multiple recordsets to my C# program. But I don't want C# code to be dependant on the physical sequence of the recordsets returned, in order to do it's job. So my question is, "Is there a way to determine which set of records from a multiplerecordset resultset am I current...

C# How can I get each column type and length and then use the lenght to padright to get the spaces at the end of each field.

I have a console application that extracts data from a SQL table to a flat file. How can I get each column type and length and then use the lenght of each column to padright(length) to get the spaces at the end of each field. Here is what I have right now that does not include this functionality. Thanks { var destinatio...

Help with Parameterizing SQL Query for C# with possible null values

Hello, people. I need help with parameterizing this query. SELECT * FROM greatTable WHERE field1 = @field1 AND field2 = @field2 The user should be able to search for any of the 2 fields, and the user also should be able to search if the field2 has null values. var query = "theQuery"; var cm = new SqlCommand(cn, query); cm.AddPara...

How do you specify 'DEFAULT' as a SQL parameter value in ADO.NET?

I have a parameterized SQL query targetted for SQL2005 which is dynamically created in code, so I used the ADO.NET SqlParameter class to add sql parameters to SqlCommand. In the aforementioned SQL I select from a Table Valued Function with has defaults. I want my dynamic sql to sometimes specify a value for these default parameters, and...

Sql Server 2005 multiple insert with c#

Hello. I have a class named Entry declared like this: class Entry{ string Id {get;set;} string Name {get;set;} } and then a method that will accept multiple such Entry objects for insertion into the database using ADO.NET: static void InsertEntries(IEnumerable<Entry> entries){ //build a SqlCommand object using(S...

What is the difference between Execute Scalar , Execute Reader and ExecuteNonQuery?

what are the different cases when we use these three.where should I use one and where should not? ...

DataSet.GetChanges - Save the updated record in a different table than the source one

I'm doing operation on a dataset containing data from a sql table named Test_1 and then get the updated records using the DataSet.GetChanges(DataRowState.Modified) function. Then i try to save the dataset containing the updated records on a different table than the source one (the table is names Test and has the same structure as Test_1)...

How to test if a DataSet is empty?

I'm modifying someone else's code where a query is performed using the following: DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(sqlString, sqlConn); da.Fill(ds); How can I tell if the DataSet is empty (i.e. no results were returned)? ...

ado.net managing connections

Hi, I'm populating a listview with a list of databases on a selected SQL instance, then retrieving a value from each database (It's internal product version, column doesn't always exist) I'm calling the below function to populate the second column of the listview: item.SubItems.Add(DBVersionCheck(serverName, database.Name)) Function D...

efficient way to check if at least one row contains a null value in a DataView ?

Hi everybody, I need to do a test in a DataView to check if at least one row contains one cell with a null value. What is the best way to do it in your opinion ? Thanks in advance. ...

Dataset and Hierarchial Data How to Sort

This is probably a dumb question, but I've hit a wall with this one at this current time. I have some data which is hierarchial in nature which is in an ADO.NEt dataset. The first field is the ID, the second is the Name, the third is the Parent ID. ID NAME Parent ID 1 Air Handling NULL 2 Compressor ...

ado.net Concurrency violation

My first time using ADO.net. Trying to make database of Users. First I populate my DataSet: adapter.AcceptChangesDuringFill = true; adapter.AcceptChangesDuringUpdate = true; adapter.Fill(dataset); To create a user: User user = new User(); user.datarow = dataset.Users.NewUsersRow(); user.Name = username; user.PasswordHash = GetHash(...

MySQL Throws NullReferenceException in Finalize... How are you coping with this?

I am using MySQL with the .Net connector on 64 bit Windows. For some reason Mysql is throwing a NullReferenceException in Finalize. This is the problem here and it seems that its due to a bug described here. This bug was reported in 6.22, but I am getting the issue with 6.23 too so apparently it is not fixed. I am using MySQL both with ...

Create Access databases programatically through vb.net

Let me preface this by saying that I know this is a stupid way to go about this, but it needs to be handled in this way. I need to make an application that from a master database creates a number of access database files (tables of a larger db), then these are manually given to users who fill in data, the database files are emailed back...