ado.net

Why wont DataGridView Update Database?

家住魔仙堡 提交于 2019-12-24 07:08:23
问题 I have a DataGridView populated with a DataSet from my Database. I am trying to make changes in the DataGridView and apply those changes to the Database whenever I press 'Enter'. Iv read alot of this same question, and researched the topic, but am still having trouble figuring out why I cannot apply changes made in my DataGridView to my Database. (I know this has been asked before, but still cant figure this out). Can anyone show me what im doing wrong? DataSet ds = new DataSet(); string

DataSet's Table name from a Stored Procedure

风格不统一 提交于 2019-12-24 06:52:05
问题 I am using a stored procedure to fill a DataSet. What I need to do is force the name of the DataTable that is created when filled. There are multiple tables returned from the Stored Procedure. The last table is the one I need to make sure has a specific name when returned. It is created by returning a value of a variable and not pulling from any tables. SELECT @Phone as My_800Number How can I make this return as table called "D1Header"? 回答1: There is no ADO.NET Native way to do it; ADO.Net

DataSet's Table name from a Stored Procedure

匆匆过客 提交于 2019-12-24 06:51:32
问题 I am using a stored procedure to fill a DataSet. What I need to do is force the name of the DataTable that is created when filled. There are multiple tables returned from the Stored Procedure. The last table is the one I need to make sure has a specific name when returned. It is created by returning a value of a variable and not pulling from any tables. SELECT @Phone as My_800Number How can I make this return as table called "D1Header"? 回答1: There is no ADO.NET Native way to do it; ADO.Net

ADO.NET Entity Framework and ADO.NET Entity Data Model?

江枫思渺然 提交于 2019-12-24 05:13:09
问题 This is confusing me a bit... When people talk about ADO.NET Entity Framework are they actually talking about ADO.NET Entity Data Model? 回答1: No, the Entity Framework includes several components such as the Entity Data Model Wizard, which allows you to create an ADO.NET Entity Data Model (via Database First or Design First workflow, or Code First). The data model is stored in an EDMX file (for Database First or Design First) and can be viewed and edited in the Entity Framework Designer. For

ADO.NET Data Services - Uploading files

二次信任 提交于 2019-12-24 04:53:33
问题 I am trying to write REST web service through which our clients can upload a file on our file server. IS there an example or any useful links which I can refer for any guidance? I haven't seen many examples of POST operation using ADO.NET data services available. 回答1: I've uploaded a file to ADO.NET dataservices using POST although I'm not sure whether it's the recommended approach. The way I went about it is: On the dataservice I've implemented a service operation called UploadFile (using

Why doesn't System.Data.SqlClient.SqlDataAdapter have a FillAsync method?

女生的网名这么多〃 提交于 2019-12-24 04:34:16
问题 Naturally-asynchronous operations are not CPU bound and don't have a thread. For example, file reads are done in the I/O hardware which can be kicked off asynchronously without a thread, enabling concurrency. Whenever I come across resources that discuss this, they always use external-system-bound operations as examples, and they almost always have "like I/O or database operations". ADO.NET has plenty of async methods, like SqlCommand.ExecuteReaderAsync , but one thing it doesn't have is

What's the most DRY-appropriate way to execute an SQL command?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 03:47:09
问题 I'm looking to figure out the best way to execute a database query using the least amount of boilerplate code. The method suggested in the SqlCommand documentation: private static void ReadOrderData(string connectionString) { string queryString = "SELECT OrderID, CustomerID FROM dbo.Orders;"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader();

Update with column name by parameter

雨燕双飞 提交于 2019-12-24 03:29:45
问题 How can I pass a columns name by parameter, follow an example DataTable dt = new DataTable(); // Here I fill my datatable for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { string columnsname = dt.Rows[i][dt.columns[j].toString()].toString(); SqlCommand comando = new SqlCommand(); comando.commandText = "UPDATE Sales.Store SET @columnname = @demographics where id = @id"; comando.Parameters.Add(new SqlParameter("@columnname", columname)); comando.Parameters

rename columnName and change column's data type in a table by using ADO.NET

偶尔善良 提交于 2019-12-24 02:45:28
问题 how can I by using Ado.net rename existing column in a table and changing a column's data type? 回答1: You can call stored procedure for that, as follows EXEC sp_rename 'MyTable.OldColumnName', 'NewColumnName' see section: Renaming a Column in this Article 来源: https://stackoverflow.com/questions/2450800/rename-columnname-and-change-columns-data-type-in-a-table-by-using-ado-net

Working with ADO.net and special characters in SQL

佐手、 提交于 2019-12-24 02:45:27
问题 I want to write a small application in Winforms, where I will be able to write some words and write them to a SQL database using ADO.net. I'm having trouble when I want to write a string with a placeholder like: Give me your '%s' right now! What is recorded in my DB is: Give me your **"%s"** right now! How can I overcome this be changing the string via C# that is transferred to my DB? This is part of my code: public virtual int Split(global::System.Nullable<int> ID, object SplitXMLDoc, string