Windows任务计划程序在运行提交给svn的批处理文件时挂起(Windows Task Scheduler hanging when running a batch file that commits to svn)
我在批处理文件中使用svn命令行客户端将单个文件提交到源代码管理。
"%TortoiseSVNPath%\svn.exe" commit %LocalPath%\backup.sql -m "Committing Backup"
这运行正常,当我运行它。 我想将它设置为每天晚上使用Windows任务计划程序运行。 但是,当我这样做时,它就陷入了这条线。 我发现问题发生是因为创建任务的用户没有登录到系统中。 有没有办法连接到svn,即使他们没有登录?
任何帮助将不胜感激。
I have the following in a batch file that uses the svn command line client to commit a single file to source control.
"%TortoiseSVNPath%\svn.exe" commit %LocalPath%\backup.sql -m "Committing Backup"
This works fine when I run it. I'd like to set it up to run every night using Windows Task Scheduler. However, when I do so, it gets stuck at that line. I've discovered that problem occurs because the user the task was created under was not logged into the system. Is there a way to connect to svn, even if they're not logged in?
Any help would be greatly appreciated.
原文:https://stackoverflow.com/questions/16488412
最满意答案
我开始写评论,但这太长了。
LINQ-to-SQL中的参数化查询应该对您有用。 像这样的东西:
StringBuilder sbSQL = new StringBuilder( "INSERT INTO [table] ([fk_id], [Description], [Title] ) VALUES"); int paramNum = 0; List<object> paramValues = new List<object>(); foreach(var item in items) { sbSQL.AppendFormat("({{{0}}},{{{1}}},{{{2}}}),", paramNum, paramNum + 1, paramNum + 2); paramValues.Add(item.fk_id); paramValues.Add(item.description); paramValues.Add(item.title); paramNum += 3; } myDataContext.ExecuteCommand( sbSQL.Remove(sbSQL.Length - 1, 1).ToString(), paramValues.ToArray());
ExecuteCommand
函数只接受您的SQL命令,其中包含与标准.NET字符串格式化函数兼容的标记({0}
),然后将您传递的值转换为参数,并使用其生成的参数名称代替标记。 您可以自己编写命令并根据需要排列参数; 它不会检查或解析命令。I started writing a comment, but this was too long.
The parameterized queries in LINQ-to-SQL should do just fine for you. Something like this:
StringBuilder sbSQL = new StringBuilder( "INSERT INTO [table] ([fk_id], [Description], [Title] ) VALUES"); int paramNum = 0; List<object> paramValues = new List<object>(); foreach(var item in items) { sbSQL.AppendFormat("({{{0}}},{{{1}}},{{{2}}}),", paramNum, paramNum + 1, paramNum + 2); paramValues.Add(item.fk_id); paramValues.Add(item.description); paramValues.Add(item.title); paramNum += 3; } myDataContext.ExecuteCommand( sbSQL.Remove(sbSQL.Length - 1, 1).ToString(), paramValues.ToArray());
The
ExecuteCommand
function just takes your SQL command, complete with tokens ({0}
) compatible with standard .NET string formatting functions, then turns the values you pass into parameters and uses its generated parameter names in place of the tokens. It's up to you to write the command and arrange the parameters however you like; it's not going to inspect or parse the command.
相关问答
更多-
SQL查询参数只取代标量值。 也就是说,你可以使用一个参数来替换你将使用常量引用字符串,常量引用日期/时间或常量数字的地方。 SQL查询参数不能用于: 表名称,列名称或其他标识符 SQL表达式 标量值列表(如在IN(...)谓词中) SQL关键字 使用用户输入来描述表结构的应用程序的正确写法是将用户输入解释为指导,而不是作为文字SQL语法。 避免传递用户输入(或任何不安全的内容)作为任何SQL语句的一部分执行。 SQL query parameters take the place of a scalar ...
-
第二种方法更好。 如果找不到客户,第一种方法将失败。 没有进行检查以确保客户ID已被退回。 如果找不到客户,第二种方法什么也不做。 如果不需要的话,为什么要创建变量呢? 基于sql的设置通常是更好的方法。 The second approach is better. The first approach will fail if the customer is not found. No check is being done to make sure the customer id has been re ...
-
短Sql插入语句?(Short Sql insert Statement?)[2022-10-09]
在Sql Server中,您不需要为标识列指定一个值(我猜这是mysql中的null所做的)。 因此,插入表格的简短语法是: Insert Into tbl Values('bla', 'bla') 无论是否将列声明为表的主键,它都适用,并且也适用于表中列的任何位置。 也就是说,即使列位于中间,如下所示: Create Table tbl ( [Col1] [varchar](50) NULL, [Id] [int] IDENTITY(1,1) NOT NULL, [Col2] [ ... -
如何正确清理(或参数化)SQL压缩插入语句(How to properly sanitize (or parameterize) SQL Compressed Insert Statement)[2023-08-11]
我开始写评论,但这太长了。 LINQ-to-SQL中的参数化查询应该对您有用。 像这样的东西: StringBuilder sbSQL = new StringBuilder( "INSERT INTO [table] ([fk_id], [Description], [Title] ) VALUES"); int paramNum = 0; List -
当您正在进行更改而不要求返回结果时,您需要调用executeUpdate()而不是executeStatement() 。 编辑 我什至不能在任何地方找到对executeStatement()的引用。 你使用executeQuery()吗? When you are making a change and not asking for a result back, you need to call executeUpdate() instead of executeStatement(). EDIT I c ...
-
使用参数和select语句创建SQL插入语句(Creating a SQL insert statement with both parameters and select statement)[2023-02-14]
这应该有效: insert into tableA values((select max(id)+1 from tableA),'text1','text') this should works : insert into tableA values((select max(id)+1 from tableA),'text1','text') -
我不确定您对如何加载数据有什么限制,但是有一些很好的途径可以在数据库中获得良好的批量导入率 - > 执行批量复制操作 。 使用数据导入过程时,我总是发现将其分解为多个阶段很有帮助: 导入阶段 - 根据您的具体情况提供各种不同的批量方法 分阶段 - 过程工作; 例如数据验证,关键关系建立,数据清理等 最终插入“实时”表格。 (希望基于插入设置) 在第一遍中选择所有数据非常有效,几乎没有逻辑工作,并将其移动到临时区域。 为此目的进入临时表或永久临时表。 然后,您可以对数据进行任何处理工作,以便在将它们大量插入到 ...
-
无法为FIRSTROW提供@variable名称。 如果要这样做,则需要通过字符串连接动态创建BULK INSERT语句,并使用EXEC或sp_execute执行它。 It's not possible to provide @variable name for FIRSTROW. If you want to do so, you need to create your BULK INSERT statement dynamically via string concatenation and execu ...
-
问题是我在insert语句中调用了row_unique_no列row_unique_id。 现在我觉得很蠢。 但是,如果有人对如何正确填充WebSQL数据库感到好奇,那么就是这样做的。 只是不要错误输入列名。 The problem was that I called the row_unique_no column row_unique_id in the insert statement. Now I feel stupid. But if anyone is curious how to popula ...
-
您不在执行sql任务中的查询中使用变量名称。 你用问号占位符替换它们,如下所示: INSERT INTO dbo.SSIS_Logging_Details (Execution_Instance_GUID, Package_Name, Execution_Date) VALUES (?, ?, GetDate()) 在参数映射中,不使用参数名称,而是使用从0开始的位置作为第一个参数。 因此将@ExecGUID替换为0并将@PackageName替换为1 。 You ...