Tag: visual studio 2010

将日期参数添加到oracle查询

我想要做的是在两个日期之间执行查询,日期将来自参数。 在下面的代码中,我正在放置一个参数,并将第二个日期设置为固定仅用于示例目的。 代码/查询有点长,可以在这里粘贴,但这里有一个简短的版本: OracleParameter fromDateParameter = new OracleParameter(); fromDateParameter.OracleDbType = OracleDbType.Varchar2; fromDateParameter.Value = “‘3/06/2013 20:00:00′”; this.oracleDataAdapter4.SelectCommand = new OracleCommand(” SELECT DISTINCT (LOG.RID) FROM LOG WHERE LOG.TIMESTAMP BETWEEN TO_DATE(:fromDateParameter, ‘MM/DD/YYYY hh24:mi:ss ‘) AND TO_DATE(‘3/06/2013 23:59:00’, ‘MM/DD/YYYY hh24:mi:ss ‘))”, oracleConnection4); oracleDataAdapter4.SelectCommand.Parameters.Add(fromDateParameter); this.oracleDataAdapter4.Fill(event11); 我收到了这条消息: ORA-01858:找到了数字所在的非数字字符 我做了相同的查询没有参数,它工作得很好。 谢谢

C#“不包含带’1’参数的构造函数”

我已经阅读了本网站上有关此错误的一些post,但我仍然无法弄清楚如何做到这一点 – 我对C#很新。 我试图将多个文本框数据(只有2个开始)从Form1传递到Form3(Form2将是我工作后添加的中介)这个想法是创建几个表单,将数据传递到最后一个表单并使用标签,Form3,然后Form3将保存所有文件或数据库。 希望有道理。 所以,这里有我的代码中的几个片段: 在Form1上我有: public Form1() { InitializeComponent(); } private void nextBtn_Click(object sender, EventArgs e) { Form3 a = new Form3(firstNameTxtBox.Text); a.Show(); Form3 b = new Form3(lastNametextBox.Text); b.Show(); this.Hide(); } 在Form3上我有: public partial class Form3 : Form { public Form3(string a, string b) { InitializeComponent(); firstNameLbl.Text = a; lastNameLbl.Text = b; } […]

为什么过时会导致错误?

我用: [Obsolete(“Use AnotherMethod() insted.”, false)] 第二个参数为false但Visual Studio为每个过时的方法调用显示Warning as Error,以防止编译项目。 如何让VS将这些调用标记为警告而不是错误?

通过表达式EPPlus格式化条件

我正在使用带有条件格式的EPPlus创建excel。 我使用C#代码进行条件格式化,但它无法正常工作。 请检查我的下面的代码,让我知道我错在哪里: ExcelPackage pck = new ExcelPackage(); var ws = pck.Workbook.Worksheets.Add(“Sample1”); var _formatRangeAddress = new ExcelAddress(“H16:K31,H33:K44,H46:K57,H59:K69,H71:K73”); string _statement = “=AND(COUNTA(H16:H16)0)”; var _cond4 = ws.ConditionalFormatting.AddExpression(_formatRangeAddress); _cond4.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; _cond4.Style.Fill.BackgroundColor.Color = Color.Green; _cond4.Formula = _statement; pck.SaveAs(Response.OutputStream); Response.ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”; Response.AddHeader(“content-disposition”, “attachment; filename=Sample1.xlsx”);

如何在提交时显示“成功”消息?

在ASP.NET中使用C#,当用户提交表单时如何显示“成功”消息? 并同时说“图像已成功保存”,带有链接,以便通过单击链接查看创建的图像?

Visual Studio无法识别System.Linq

我创建了这个程序和C#,几周前它正常工作。 现在,我将所有这些代码复制到我正在处理的另一个项目中。 我将它添加到我正在进行的项目中的全新C#类中。 Visual Studio无法识别注释中“未找到”的程序集引用。 这是奇怪的,因为它们是在之前的程序中找到的。 有谁知道为什么Visual Studio找不到这些程序集引用。 using System; using System.Collections.Generic; using System.Linq; //not found using System.Text; using XML_Creator; //not found using System.Xml.Linq; //not found using System.IO;

安装Visual Studio 11 beta后,不再通过Visual Studio 2010执行测试

我用Visual-Studio-2010 Ultimate创建了许多TestProjects。 所有测试都成功执行(它们是简单的unit testing)。 现在我安装了Visual-Studio-11 beta ,我意识到它们不是通过VS-2010执行的。 我也从命令行通过MSTest(2010)尝试了它,没有成功。 测试执行似乎开始(并且永远不会结束)但是在没有报告任何错误的情况下不执行测试。 通过VS-11一切正常。 有没有人有同样的问题?

使用全局高速缓存时,如何修复CA2000 IDisposable C#编译器警告

CA2000是关于IDisposable接口的警告: CA2000:Microsoft.Reliability:在方法’ImportProcessor.GetContext(string)’中,在对所有引用超出范围之前,在对象’c’上调用System.IDisposable.Dispose。 我的方法用于存储上下文缓存,如下所示: public class RegionContext : IDisposable { /* Implement Dispose() here */ } private Dictionary contextCache = new ….. (); public RegionContext GetContext(string regionCode) { RegionContext rc = null; if (!this.contextCache.TryGetValue(regionCode.ToUpper(), out rc)) { rc = new RegionContext(regionCode); this.contextCache.Add(regionCode.ToUpper(), rc); } return rc; } 你会在哪里使用修复此编译器警告的using()语句? 我的外部类实际上在自己的实现中迭代并处理contextCache中的内容。 我要压制它,还是有办法正确摆脱这个警告?

在任何按钮中单击的事件(C#窗体)

我正在开发一个程序,它有许多按钮,点击时应该执行类似的操作,但根据点击的按钮有很小的差异。 问题是唯一直接的路径是为每个按钮编写代码,这将是一个非常重复的任务。 有没有办法只编程一个块,可以点击任何按钮,单击哪个按钮?

XSD:使用Visual Studio xsd.exe不生成Array 而不是List

我使用xsd.exe工具从xsd文件生成类。 xsd文件: 输出是: /// [System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”, “4.0.30319.1”)] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute(“code”)] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] [System.Xml.Serialization.XmlRootAttribute(Namespace=””, IsNullable=false)] public partial class BAXML { private string counterpartyOrgNrField; private BAXMLLimit[] limitField; /// [System.Xml.Serialization.XmlElementAttribute(“Limit”)] public BAXMLLimit[] Limit { get { return this.limitField; } set { this.limitField = value; } }} /// [System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”, “4.0.30319.1”)] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute(“code”)] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class BAXMLLimit { private string […]