system.data

Table Property broken after C# Typed DataSet Copy()

半腔热情 提交于 2019-12-13 04:32:42
问题 I've got a typed DataSet with multiple tables that I want copy, complete with data as well as schema. I can access the tables like so in my original: MyDataSetType dsMyFirstDataSet; MyDataTableType dtTable1; MyDataTableType dtTable2; dtTable1 = dsMyFirstDataSet.MeaningfulTableName1; dtTable2 = dsMyFirstDataSet.MeaningfulTableName2; When I do the following, I can no longer access the tables via the names in the new version but I can via the Tables collection. MyDataSetType dsMySecondDataSet;

Uploading DataTable to Azure blob storage

喜夏-厌秋 提交于 2019-12-10 11:17:20
问题 I am trying to serialize a DataTable to XML and then upload it to Azure blob storage. The below code works, but seems clunky and memory hungry. Is there a better way to do this? I'm especially referring to the fact that I am dumping a memory stream to a byte array and then creating a new memory stream from it. var container = blobClient.GetContainerReference("container"); var blockBlob = container.GetBlockBlobReference("blob"); byte[] blobBytes; using (var writeStream = new MemoryStream()) {

.NET System Type to SqlDbType

孤人 提交于 2019-12-09 08:27:43
问题 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 value try { if (name.Contains("16") || name.Contains("32") || name.Contains("64")) { name = name.Substring(0, name.Length - 2); } val = (SqlDbType)Enum.Parse(typeof(SqlDbType), name, true); } catch (Exception) { // add error handling to suit your taste } return

The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data'

丶灬走出姿态 提交于 2019-12-07 05:30:02
问题 When trying to run my code, I receive the following error: CS0234: The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) I have included references to System.Data.dll and System.Data.OracleClient.dll , but I am still getting this error. The error is being caused by the line using System.Data.OracleClient in my namespace declaration. 回答1: The using System.Data.OracleClient directive means that that namespace should be

Uploading DataTable to Azure blob storage

烈酒焚心 提交于 2019-12-06 10:51:38
I am trying to serialize a DataTable to XML and then upload it to Azure blob storage. The below code works, but seems clunky and memory hungry. Is there a better way to do this? I'm especially referring to the fact that I am dumping a memory stream to a byte array and then creating a new memory stream from it. var container = blobClient.GetContainerReference("container"); var blockBlob = container.GetBlockBlobReference("blob"); byte[] blobBytes; using (var writeStream = new MemoryStream()) { using (var writer = new StreamWriter(writeStream)) { table.WriteXml(writer, XmlWriteMode.WriteSchema);

System.Data Assembly Not found

只谈情不闲聊 提交于 2019-12-04 05:36:30
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 cannot find the file specified. I attach the FusionLog to my code and found out the following. For System.Data only visual studio is looking here: Assembly manager loaded from: C:\windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll And it should be looking here (all the other assemblies are but System.Data) Assembly manager loaded from: C:

.NET System Type to SqlDbType

我的未来我决定 提交于 2019-12-03 11:41:36
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 value try { if (name.Contains("16") || name.Contains("32") || name.Contains("64")) { name = name.Substring(0, name.Length - 2); } val = (SqlDbType)Enum.Parse(typeof(SqlDbType), name, true); } catch (Exception) { // add error handling to suit your taste } return val; } The code above is not really nice and is a code smell, which is why I wrote the following,

WinRT System.Data - Connect to SQL

大城市里の小女人 提交于 2019-11-29 08:26:40
Just want to make sure I am not missing something. There does not appear to be a WinRT System.Data. What I am looking for is System.Data.SqlClient to connect to SQL. Can a Metro App connect to SQL? If yes can a Metro App connect to SQL in a App Store compliant manner. You are correct, System.Data is not there (I looked for the same thing when I first started messing around with WinRT). You won't be able to reference it either. If you want to talk to a SQL database you're going to need to use some kind of other protocol (WebService, SOAP, WCF, etc.). There are ports for SQLite available that

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

删除回忆录丶 提交于 2019-11-29 04:07:17
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 = dt.NewRow(); var item = dr.Item["myItem"]; I can't make it run under C#, the problems I have is the third row var item = dr.Item["myItem"]; : System.Data.DataRow' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.DataRow' could be found (are you missing a using directive or an assembly

WinRT System.Data - Connect to SQL

删除回忆录丶 提交于 2019-11-28 01:39:57
问题 Just want to make sure I am not missing something. There does not appear to be a WinRT System.Data. What I am looking for is System.Data.SqlClient to connect to SQL. Can a Metro App connect to SQL? If yes can a Metro App connect to SQL in a App Store compliant manner. 回答1: You are correct, System.Data is not there (I looked for the same thing when I first started messing around with WinRT). You won't be able to reference it either. If you want to talk to a SQL database you're going to need to