c#-2.0

OleDbConnection Source Variable in C#

ぃ、小莉子 提交于 2021-02-20 03:49:46
问题 How can I replace D:\temp\test.xls with filePath in OleDbConnection statement. I can get the exactly filePath (with OpenFileDialog, then I can located my .xls file conveniently, no more hardcoded), but when I insert the variable filePath as Style2, it doesn't work. How can I fix this ? Thanks. Style1 OleDbConnection dbConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\test.xls;Extended Properties=""Excel 8.0;HDR=Yes;"""); Style2 OleDbConnection

C# ImageButton Click event not fired

ε祈祈猫儿з 提交于 2021-01-28 05:52:06
问题 Code first: public class ExtendedGridView : GridView { private ImageButton m_btnPrint; public ImageButton PrintButton { get { return m_btnPrint; } set { m_btnPrint = value; } } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); PrintButton = new ImageButton(); PrintButton.Click += new ImageClickEventHandler(OnPrintButtonClick); PrintButton.AlternateText = "Print"; PrintButton.ImageUrl = "../../Images/Print.png"; TableCell cell = new TableCell(); cell.Controls.Add

how to handle exception for IHostBuilder CreateHostBuilder

廉价感情. 提交于 2020-08-09 08:14:51
问题 To simulate the error, I gave the wrong azure key vault address. With the below code; I tried all the possible ways to try/catch the exception, but still I get an error when the app is start. How do I handle this exception so the application does NOT throw the error during startup? I have ASP.NET Core 3.1 web API application. HTTP Error 500.30 - ANCM In-Process Start Failure The actual reason for the error is that I put wrong key vault address, System.Net.Http.HttpRequestException: 'No such

Create List<int> with values at compile time

独自空忆成欢 提交于 2020-05-25 08:59:29
问题 It is possible to create an array at compile time like; int[] myValues = new int[] { 1, 2, 3 } ; But I would like to do something like this; List<int> myValues = new List<int>() { 1, 2, 3 }; The compiler says No. Is there a way to do this (C# 2.0) without using LINQ (C# 3.0)? 回答1: List<int> myValues = new List<int>(new int[] { 1, 2, 3 } ); This will create an intermediate array however so there may be a more efficient way of doing the same thing. EDIT: John Feminella suggested creating a

IEquatable, how to implement this properly [duplicate]

…衆ロ難τιáo~ 提交于 2020-05-09 07:04:32
问题 This question already has answers here : Is there a complete IEquatable implementation reference? (5 answers) Closed 3 days ago . I am using .net 2.0 and c# and I have implemented the IEquatible interface in my class like this:- public MyClass() : IEquatable<MyClass> { Guid m_id = Guid.NewGuid(); public Guid Id { get { return m_id; } } #region IEquatable<MyClass> Members public bool Equals(MyClass other) { if (this.Id == other.Id) { return true; } else { return false; } } #endregion } Is this

how can i access string variable value of .aspx.cs file in .aspx file

◇◆丶佛笑我妖孽 提交于 2020-02-05 06:38:07
问题 i m getting a string value regression as regression = (Session["Regression"]).ToString(); in .aspx.cs file then i want to use this value in .aspx file in SelectCommand of SqlDataSource property as below SelectCommand="SELECT [issue_oid], [issue_num], [regression], [status], [tested_by], [tested_on], [patch_name], [arrived_on], [previous_info], [comment], [is_duplicate] FROM [itt_monthly_patch_issue_list] where status='Not Tested' and `regression='<%#regression%>'"` .aspx.cs file page_load