ado.net

Retrieve output parameter of SQL statement

心已入冬 提交于 2021-01-27 05:07:30
问题 I'm using a table with two columns, customer_id and customer_name . customer_name is a simple varchar , customer_id is an auto incrementing primary key. I want to use my C# application to insert a customer_name , and retrieve the value of the customer_id . Just inserting is simply solved by using using (SqlConnection connection = new SqlConnection(AppConstants.ConnectionString)) { using (SqlCommand command = new SqlCommand("INSERT INTO custom_customer (customer_name) VALUES (@name);")) {

Retrieve output parameter of SQL statement

心不动则不痛 提交于 2021-01-27 05:04:26
问题 I'm using a table with two columns, customer_id and customer_name . customer_name is a simple varchar , customer_id is an auto incrementing primary key. I want to use my C# application to insert a customer_name , and retrieve the value of the customer_id . Just inserting is simply solved by using using (SqlConnection connection = new SqlConnection(AppConstants.ConnectionString)) { using (SqlCommand command = new SqlCommand("INSERT INTO custom_customer (customer_name) VALUES (@name);")) {

Retrieve output parameter of SQL statement

泄露秘密 提交于 2021-01-27 05:02:28
问题 I'm using a table with two columns, customer_id and customer_name . customer_name is a simple varchar , customer_id is an auto incrementing primary key. I want to use my C# application to insert a customer_name , and retrieve the value of the customer_id . Just inserting is simply solved by using using (SqlConnection connection = new SqlConnection(AppConstants.ConnectionString)) { using (SqlCommand command = new SqlCommand("INSERT INTO custom_customer (customer_name) VALUES (@name);")) {

Affected Rows Entity Framework

人走茶凉 提交于 2021-01-22 23:16:51
问题 How do I get the number of rows affected after a SaveChanges()? 回答1: The SaveChanges Method returns an int of all items changed. MSDN Snippet: Return Value Type: System.Int32 The number of objects in an Added, Modified, or Deleted state when SaveChanges was called. 来源: https://stackoverflow.com/questions/996629/affected-rows-entity-framework

Errors with declared array/table variable values in SAP HanaDB SQL

*爱你&永不变心* 提交于 2021-01-05 07:35:40
问题 I am trying to add a declared variable to replace a hardcoded list of values in a "where in" clause. Researching how Hana handles array variables it seems like I can do this by declaring an array and then either using a select directly on it or by unnesting it first into a table but I keep getting errors I can't resolve. When I try it this way: DO BEGIN DECLARE CODES_ARRAY NVARCHAR(100) ARRAY = ARRAY('01','02','03','04'); SELECT T0."ItemCode" FROM OITM T0 INNER JOIN OITW T1 ON T0."ItemCode" =

Errors with declared array/table variable values in SAP HanaDB SQL

你说的曾经没有我的故事 提交于 2021-01-05 07:32:53
问题 I am trying to add a declared variable to replace a hardcoded list of values in a "where in" clause. Researching how Hana handles array variables it seems like I can do this by declaring an array and then either using a select directly on it or by unnesting it first into a table but I keep getting errors I can't resolve. When I try it this way: DO BEGIN DECLARE CODES_ARRAY NVARCHAR(100) ARRAY = ARRAY('01','02','03','04'); SELECT T0."ItemCode" FROM OITM T0 INNER JOIN OITW T1 ON T0."ItemCode" =

ExecuteNonQueryAsync and commit in a SQL Transaction

送分小仙女□ 提交于 2020-12-29 12:00:43
问题 I am after some help with a piece of code I have created, I am attempting to make an Async SQL call from c# within a transaction, for example I might be updating or deleting rows from a table. This is what I have so far, but I cannot seem to find much information on doing this in a transaction, from what I have here and what I understand so far, I believe it may attempt to commit the transaction before the command has fully completed if the command is time-consuming. If you could advise /

ExecuteNonQueryAsync and commit in a SQL Transaction

折月煮酒 提交于 2020-12-29 12:00:23
问题 I am after some help with a piece of code I have created, I am attempting to make an Async SQL call from c# within a transaction, for example I might be updating or deleting rows from a table. This is what I have so far, but I cannot seem to find much information on doing this in a transaction, from what I have here and what I understand so far, I believe it may attempt to commit the transaction before the command has fully completed if the command is time-consuming. If you could advise /

Xamarin: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

倖福魔咒の 提交于 2020-12-26 04:45:06
问题 In Xamarin. I've been trying to make communications between my Web API and my Xamarin project. Here's the code for my controller: // GET api/values public List<string> Get() { List<string> values = new List<string>(); values.Add("Value 1"); values.Add("Value 2"); return values; } And here is my GET request in my MainPage.xaml.cs public async void BindToListView() { HttpClient client = new HttpClient(); var response = await client.GetStringAsync("https://10.0.2.2:#####/api/Values"); var posts

Using TransactionScope with Stored Procedure Transaction does not work

耗尽温柔 提交于 2020-12-13 03:32:35
问题 As per my understanding, C# TransactionScope can still work when wrapping a T-SQL BEGIN / COMMIT TRANSACTION inside a stored procedure. I have the following C# method which does EF Save first, then call a stored procedure that has its own transaction and then call external service over HTTP public async Task DoSomething(MyDto dto) { using (var scope = new TransactionScope()) { //Save First var myEntity = await _dbContext.MyEntity.Where(x=>x.Id == dto.Id).SingleOtDefaultAsync(); // Assign