c#-4.0

Oracle query is not working in C#

a 夏天 提交于 2020-01-15 07:15:28
问题 When I run this code it always returning zero while when i run this query in oracle sql client it returns 1. var strSQL = string.Format("SELECT COUNT(*) FROM GANTNER.GAT_REASONS WHERE CODE ='{0}'", StatusCode); objCmd = new OracleCommand(strSQL, objConn); objCmd.CommandType = CommandType.Text; int val = int.Parse(objCmd.ExecuteScalar().ToString()); For try I remove condition on column name CODE and it works but when I put column name CODE it does not then I tried to put "CODE" 'CODE' all not

Oracle query is not working in C#

余生颓废 提交于 2020-01-15 07:14:49
问题 When I run this code it always returning zero while when i run this query in oracle sql client it returns 1. var strSQL = string.Format("SELECT COUNT(*) FROM GANTNER.GAT_REASONS WHERE CODE ='{0}'", StatusCode); objCmd = new OracleCommand(strSQL, objConn); objCmd.CommandType = CommandType.Text; int val = int.Parse(objCmd.ExecuteScalar().ToString()); For try I remove condition on column name CODE and it works but when I put column name CODE it does not then I tried to put "CODE" 'CODE' all not

Can't get multiview control to change views

三世轮回 提交于 2020-01-15 06:36:18
问题 I have a multiview control, that has two views. View1 is the default view, and View2 is the new view. When the end user click a button, I want to change the view to View2. I can't seem to achieve this anyway I go. ASP.NET Code: <asp:MultiView ID="MVOrder" runat="server"> <asp:View ID="VOrderNow" runat="server"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <table> <tr> <td> <asp:Label ID="LblInfo" runat="server"></asp:Label> </td> <td>  </td> <td> </td> </tr> <tr> <td>

Is Task.ContinueWith thread safe?

非 Y 不嫁゛ 提交于 2020-01-15 06:18:42
问题 I have multiple threads that enqueue actions to the same task using ContinueWith() Is it thread safe? Or should I wrap it with some dedicated lock? 回答1: It is thread safe. It even works when the task has already completed. 来源: https://stackoverflow.com/questions/31165280/is-task-continuewith-thread-safe

Is Task.ContinueWith thread safe?

坚强是说给别人听的谎言 提交于 2020-01-15 06:17:57
问题 I have multiple threads that enqueue actions to the same task using ContinueWith() Is it thread safe? Or should I wrap it with some dedicated lock? 回答1: It is thread safe. It even works when the task has already completed. 来源: https://stackoverflow.com/questions/31165280/is-task-continuewith-thread-safe

How to use Threadpool.QueueUserWorkItem in a windows service?

不打扰是莪最后的温柔 提交于 2020-01-15 06:17:07
问题 I have a windows service where I am using Threadpool.QueueUserWorkItem. The service connects to multiple client databases, grabs data, converts to XLS and send files to the corresponding FTP. I have 3 questions regarding the code below: Am I using the Threadpool.QueueUserWorkItem correctly? Do I need to use Lock anywhere in the code to avoid issues? If yes, where and to what object. Is there anything that is not correct in the code? If yes, what and how to deal with it? Code: private static

How to use Threadpool.QueueUserWorkItem in a windows service?

心不动则不痛 提交于 2020-01-15 06:16:58
问题 I have a windows service where I am using Threadpool.QueueUserWorkItem. The service connects to multiple client databases, grabs data, converts to XLS and send files to the corresponding FTP. I have 3 questions regarding the code below: Am I using the Threadpool.QueueUserWorkItem correctly? Do I need to use Lock anywhere in the code to avoid issues? If yes, where and to what object. Is there anything that is not correct in the code? If yes, what and how to deal with it? Code: private static

Singleton Alternative - is it equivalent?

孤街浪徒 提交于 2020-01-15 05:31:09
问题 Quick question - I know that the standard singleton pattern is as follows: Original public class Singleton1 { public static Singleton1 _Instance; public static Singleton1 Instance { get { if (_Instance == null) { _Instance = new Singleton1(); } return _Instance; } } private Singleton1() { } } But it seems like this code is unnecessary. To me, you could accomplish the same thing with either of the following simple design patterns: Version 2 public class Singleton2 { public static readonly

Singleton Alternative - is it equivalent?

前提是你 提交于 2020-01-15 05:30:45
问题 Quick question - I know that the standard singleton pattern is as follows: Original public class Singleton1 { public static Singleton1 _Instance; public static Singleton1 Instance { get { if (_Instance == null) { _Instance = new Singleton1(); } return _Instance; } } private Singleton1() { } } But it seems like this code is unnecessary. To me, you could accomplish the same thing with either of the following simple design patterns: Version 2 public class Singleton2 { public static readonly

TPL Tasks & Stored procedures

前提是你 提交于 2020-01-15 04:49:10
问题 I was wondering if it is possible to call a number of different stored procedures with the same parameters asynchronously by using tasks and then waiting for all the results to return. I have the following: private Task<DataTable> DataBaseCall(string procedureName, params Pair[] where) { DataTable data = new DataTable(); SqlConnection connection = new SqlConnection(connStr); SqlCommand command = new SqlCommand(procedureName, connection); connection.Open(); for (int i = 0; i < where.Length; i+