Questions tagged [system.data]

System.Data is a namespace of the .NET framework. It provides access to classes that represent the ADO.NET architecture.

System.Data is a namespace of the .NET framework. It provides access to classes that represent the ADO.NET architecture.

References

161 questions
52
votes
8 answers

Why use a using statement with a SqlTransaction?

I've been running into some problems concerning a SqlTransaction I'm using in my code. During my Googling I see many people using a using statement with a SqlTransaction. What is the benefit and/or difference of using this type of statement with a…
35
votes
1 answer

What is the purpose of using CommandType.Tabledirect?

How is the option CommandType.Tabledirect used unlike CommandType.StoredProcedure or CommandType.Text?
Venil
  • 405
  • 2
  • 5
  • 10
20
votes
2 answers

How can I manually / programmatically create a DataRow?

My project's codebase has a legacy method that takes a DataRow as a parameter for which I would like to create a unit test method. How can I manually create a DataRow object to pass to the method? The System.Data.DataRow class doesn't have a…
Jon Schneider
  • 25,758
  • 23
  • 142
  • 170
20
votes
4 answers

.NET System Type to SqlDbType

I was looking for a smart conversion between .Net System.Type and SqlDbType. What I found it was the following idea: private static SqlDbType TypeToSqlDbType(Type t) { String name = t.Name; SqlDbType val = SqlDbType.VarChar; // default…
Simone Salvo
  • 343
  • 1
  • 2
  • 11
16
votes
1 answer

'4' and '4' clash in primary key but not in filesystem

There is DataTable with primary key to store information about files. There happen to be 2 files which differ in names with symbols '4' and '4' (0xff14, a "Fullwidth Digit Four" symbol). The DataTable fails to include them both because of failed…
max630
  • 8,762
  • 3
  • 30
  • 55
16
votes
2 answers

How to open a System.Data.SQLClient.SQLConnection with Active Directory Universal Authentication

I was using the below code to connect to SQL Azure DB that was using Active Directory Integrated Authentication. private string GenerateConnectionString(string databaseName, string serverName) { SqlConnectionStringBuilder connBuilder = new…
shanmuga raja
  • 685
  • 6
  • 19
10
votes
2 answers

In C#: Why no 'Item' on System.Data.DataRow?

I'm rewriting/converting some VB-Code: Dim dt As New System.Data.DataTable() Dim dr As System.Data.DataRow = dt.NewRow() Dim item = dr.Item("myItem") C#: System.Data.DataTable dt = new System.Data.DataTable(); System.Data.DataRow dr =…
sl3dg3
  • 5,026
  • 12
  • 50
  • 74
9
votes
3 answers

System.Data Assembly Not found

I have a reference to System.Data in my windows service project. I keep getting the Exception : Could not load file or assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system…
Nick LaMarca
  • 8,076
  • 31
  • 93
  • 152
8
votes
1 answer

Custom .NET Data Providers

Is is possible to use a custom .NET data provider without installing it in the GAC? Can I reference a custom DLL and register it inside my configuration file?
7
votes
1 answer

c# unit testing, mocking stored procedure

In the past when I have been implementing unit test I have struggled to set up 'decent' unit tests for data access layers because they often have a database as an external dependency. In an ideal world I would mock the stored procedure calls so…
C. Knight
  • 739
  • 2
  • 5
  • 20
6
votes
2 answers

SqlDataReader.GetSqlBinary vs SqlDataReader.GetSqlBytes?

Under the namespace System.Data.SqlClient, we have both SqlDataReader.GetSqlBinary and SqlDataReader.GetSqlBytes. Both seems to give "raw data". If so, what's the difference between them?
TwentyTwo
  • 177
  • 7
6
votes
2 answers

DataRow constructor inaccessible when writing DataSet extension?

I am trying to write a couple of extensions to convert UniDataSets and UniRecords to DataSet and DataRow but I get the following error when I try to compile. 'System.Data.DataRow.DataRow(System.Data.DataRowBuilder)' is inaccessible due to its…
josh
  • 530
  • 1
  • 5
  • 19
6
votes
3 answers

How do You Get a Specific Value From a System.Data.DataTable Object?

I'm a low-level algorithm programmer, and databases are not really my thing - so this'll be a n00b question if ever there was one. I'm running a simple SELECT query through our development team's DAO. The DAO returns a System.Data.DataTable object…
Giffyguy
  • 20,378
  • 34
  • 97
  • 168
5
votes
2 answers

.NET System.Data namespace decompilation: where can I find the code relating to SQL Server concurrency violations

Where in the .NET System.Data namespace is the code that determines, when the update-command is executed, whether a row in a SQL Server 2K table has been changed after the client program had read it in, i.e. that the client-side version of the row…
Tim
  • 8,669
  • 31
  • 105
  • 183
5
votes
2 answers

Why to use using statement on DbTransaction in ADO.NET / C#?

I understood the implicit rollback (that usually happens when exception happens and Dispose is called) is not guaranteed for all providers. However many examples uses: using (DbTransactio txn = cnctn.BeginTransaction()) is there a reason for that?
char m
  • 7,840
  • 14
  • 68
  • 117
1
2 3
10 11