Before I create a column or table in a SQL Server database I want to check if the required table and/or columns exist. I have searched around and found 2 ways so far. Stored procedures, which I don't want to use By using the SqlCommand.ExecuteScalar() method and catching an exception to determine if the table/column exists, which for me is a work around but not a perfect solution. Is
在SQL Server数据库中创建列或表之前,我想检查所需的表和/或列是否存在。 到目前为止,我搜索了两种方法。 存储过程,我不想使用 通过使用SqlCommand.ExecuteScalar()方法并捕获一个异常来确定表/列是否存在,这对我来说是一种解决方法,但不是一个完美的解决方案。 是否有另一种方法来检查SQL Server中是否存在表/列? 要在创建模式之前检查模式是否存在,请执行以下操作: 检查列是否存在; 你使用IF NOT EXISTS
I am trying to check if a column exists and if not, add it. I've tried a couple of solutions including this, but the syntax isn't correct for Access db. This is what I have so far: public void Update(string task, string dbPath, string tableName = "Frames") { OleDbConnection db = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;data source=" + dbPath); db.O
我试图检查列是否存在,如果不存在,添加它。 我已经尝试了几个解决方案,包括这个,但是Access数据库的语法不正确。 这是我到目前为止: public void Update(string task, string dbPath, string tableName = "Frames") { OleDbConnection db = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;data source=" + dbPath); db.Open(); OleDbCommand command = db.CreateCommand();
This question already has an answer here: How do I perform an IF…THEN in an SQL SELECT? 22 answers Can you have if-then-else logic in SQL? [duplicate] 7 answers 一种方法是select和case : select (case when exists (select X from table1 where x = 'value1') then 1 when exists (select x from table2 where x = 'value2') then 2 else 0 end
这个问题在这里已经有了答案: 如何在SQL SELECT中执行IF ... THEN? 22个答案 你可以在SQL中有if-then-else逻辑吗? [复制] 7个答案 一种方法是select和case : select (case when exists (select X from table1 where x = 'value1') then 1 when exists (select x from table2 where x = 'value2') then 2 else 0 end) as flag 是否可以用变量来实现: D
I have a long string (500,000+ characters) that contains an RSS feed in XML format. I'm trimming some parts of the XML to clean up the information before parsing it. However, when I call this code: string rssData = string.Empty; //Get RSS data here rssData = rssData.Replace("\"", string.Empty); The backslash characters are not removed. Is there a limitation to doing replacements of a cha
我有一个长字符串(500,000多个字符),其中包含XML格式的RSS源。 我正在修剪XML的某些部分以在分析信息之前清理信息。 但是,当我调用此代码时: string rssData = string.Empty; //Get RSS data here rssData = rssData.Replace("\"", string.Empty); 反斜杠字符不会被删除。 当字符串很长时,对字符进行替换是否存在限制? 以下是被替换的字符串示例。 我删除反斜杠以正确解析引号: <?xml version="1.0" encoding
I am currently developing a desktop application in WPF, which uses an .NET Core library to make porting to different platforms easier. However, I cannot seem to reference the .NET Core library from the WPF app. I tried the follwing solutions: Reference the project: Visual Studio complains about the project not being an .exe or .dll even though it is. Reference the compiled .dll: This is re
我目前正在WPF中开发一个桌面应用程序,该应用程序使用.NET Core库来轻松移植到不同的平台。 但是,我似乎无法从WPF应用程序中引用.NET Core库。 我尝试了以下解决方案: 引用该项目:Visual Studio抱怨该项目不是.exe或.dll,尽管它是。 引用编译后的.dll:这真的很难看,但它起初似乎起作用。 智能感知是可以的,WPF项目编译得很好。 但是,只要我想使用.NET Core项目中的任何功能,就会抛出BadImageFormatException
Given below is a sample console application uses jabber-net client for sending a sample test message after authenticating the connection. I am receiving error while authenticating the login request.Error is given below. "Unable to read data from the transport connection: A non-blocking socket operation could not be completed immediately. " I am new into this XMPP. So many projects
下面给出了一个示例控制台应用程序使用jabber-net客户端在认证连接后发送样本测试消息。 我在验证登录请求时收到错误。下面给出错误。 “无法从传输连接读取数据:不能立即完成非阻塞套接字操作。” 我是这个XMPP的新手。 在线提供的许多项目,但都没有发现相关性。 请提供您的宝贵信息或链接,以便为我的应用程序开发免费的jabber客户端库。 示例代码如下所示! class Program { // we will wait on this event unti
Overview I am sending messages back and forth between a client (Android phone) and a Server (Windows Server). Using a persistent connection over TCP, which protocol would be the best solution. I am looking at performance, scalability, size of messages, and battery life. The messages must arrive at the destination in order and can not be duplicates. MQTT This seems like the better solutio
概观 我在客户端(Android手机)和服务器(Windows Server)之间来回发送消息。 通过TCP使用持久连接,哪种协议将是最佳解决方案。 我正在研究性能,可扩展性,消息大小和电池寿命。 消息必须按顺序到达目的地,并且不能重复。 MQTT 这似乎是更好的解决方案,但似乎有很多用户大量实施的例子。 我不确定我是否可以将其集成到Windows服务器中,或者它是否必须是另一个应用程序或服务器正在运行。 最后似乎总体上缺乏关
I'm making simple XMPP client using Jabber-Net. To send simple message i'm using a way from example code, ie: jabber.protocol.client.Message msg = new jabber.protocol.client.Message(jc.Document); msg.To = "adress@jabber.com"; msg.Body = "hello world"; jc.Write(msg); it works fine, but I would like to send chat message . I mean that in PSI (http://psi-im.org/) i can send to somebody si
我正在使用Jabber-Net制作简单的XMPP客户端。 发送简单的消息,我使用了一个来自示例代码的方式,即: jabber.protocol.client.Message msg = new jabber.protocol.client.Message(jc.Document); msg.To = "adress@jabber.com"; msg.Body = "hello world"; jc.Write(msg); 它工作正常,但我想发送聊天消息 。 我的意思是说,在PSI(http://psi-im.org/)中,我可以发送给某人简单的信息,或者在聊天时与他交谈(为此另一种形
Possible Duplicate: Sanitize table/column name in Dynamic SQL in .NET? (Prevent SQL injection attacks) I have a query like so: "SELECT * FROM MyTable_" + myID + " WHERE variable = @variable"; The SQL Parameterization works with variables, but how do I get it to work with table names? myID is an int I get passed in and changed (can be converted to string), but how do I protect against sql
可能重复: 在.NET中动态SQL中清理表/列名称? (防止SQL注入攻击) 我有这样的查询: "SELECT * FROM MyTable_" + myID + " WHERE variable = @variable"; SQL参数化适用于变量,但我如何才能使用它来处理表名? myID是一个int我传入并更改(可以转换为字符串),但我如何防止SQL注入在这里? 我质疑你为什么要这样做,但你可以查看sys.tables来获得最终的白名单。 DECLARE @TableName VARCHAR(100) = 'Table to Lo
We are having another discussion here at work about using parametrized sql queries in our code. We have two sides in the discussion: Me and some others that say we should always use parameters to safeguard against sql injections and the other guys that don't think it is necessary. Instead they want to replace single apostrophes with two apostrophes in all strings to avoid sql injections. O
在我们的代码中,我们正在进行另一个关于使用参数化SQL查询的讨论。 我们有两方面的讨论:我和其他一些人说,我们应该总是使用参数来防止sql注入和其他人认为这是不必要的。 相反,他们希望用所有字符串中的两个撇号替换单撇号以避免sql注入。 我们的数据库都运行Sql Server 2005或2008,我们的代码库运行在.NET框架2.0上。 让我在C#中给你一个简单的例子: 我希望我们使用这个: string sql = "SELECT * FROM Users WHE