如何使用相同的数据源发布多个Lightswitch HTML项目(How to publish multiple Lightswitch HTML projects using the same data source)
我在2012 Server上使用IIS 8.5,在同一台机器上使用Visual Studio和SQL Server。
我已经构建并发布了一个Lightswitch HTML客户端,它在Web浏览器中运行良好。 它是一个内部应用程序,可以在http:// servername / htmlclient上的域计算机上访问/工作。 这是Lightswitch发布HTML内容的默认位置。
我还构建了第二个LS HTML项目。 它完全独立但使用相同的SQL数据源。 我似乎无法成功地将这个项目发布到网上。 老实说,我不确定它是否是一个Visual Studio / Lightswitch问题,一个IIS问题...我有点迷失为什么它不能“正常工作”,就像我发布的第一个应用程序一样。 即使考虑到我在尝试发布时遇到的错误,我也不确定如何解决问题。
对于新项目生成web.config文件似乎存在问题,或者可能与使用相同数据源的两个项目有关。 这是我在尝试在Web浏览器中查看第二个项目的内容时遇到的错误...
I am using IIS 8.5 on a 2012 Server, with Visual Studio and SQL Server on the same machine.
I have built and published one Lightswitch HTML Client, and it is working fine from web browsers. It is an internal application and is accessible/working on domain computers at http://servername/htmlclient. This is the default location where Lightswitch publishes the HTML content.
I have also built a second LS HTML project. It is completely separate but uses the same SQL data source. I cannot seem to successfully publish this project to the web, at all. I am honestly not sure if it is a Visual Studio/Lightswitch issue, an IIS issue... I am kind of lost as to why it doesn't 'just work', like the first application I published. Even given the error I am seeing when I try to publish, I am not sure how to fix the issue.
It appears to be a problem with generating a web.config file for the new project, or maybe something to do with both projects using the same data source. This is the error I get when trying to view the content of the second project in a web browser...
原文:https://stackoverflow.com/questions/34291912
最满意答案
在第一个代码示例中,每次迭代都会创建一个新的
SqlCommand
:SqlCommand command = new SqlCommand(insertQuery, connection);
在第二个中,所有迭代都修改相同的命令,添加越来越多的参数。 只有第一个调用具有正确数量的参数,下一个调用具有太多参数。
在没有值的循环之前添加参数,然后在循环中设置值并执行命令
command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "InsertBets"; command.Parameters.Add("@FixtureId", SqlDbType.Int); // add the other paramters foreach (Bet bet in bets) { command.Parameters["@FixtureId"].Value = bet.FixtureId; // set the other parameters command.ExecuteNonQuery(); }
In the first code sample a new
SqlCommand
is created in every iteration:SqlCommand command = new SqlCommand(insertQuery, connection);
In the 2nd one, all iterations modify the same command, adding more and more parameters. Only the first call will have the correct number of parameters, the next ones have too many.
Add the parameters before the loop without values, then in the loop set the values and execute the command
command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "InsertBets"; command.Parameters.Add("@FixtureId", SqlDbType.Int); // add the other paramters foreach (Bet bet in bets) { command.Parameters["@FixtureId"].Value = bet.FixtureId; // set the other parameters command.ExecuteNonQuery(); }
相关问答
更多-
为什么foreach循环不适用于C#中的datagridview选定行?(Why foreach loop does not work with datagridview selected rows in C#?)[2022-11-11]
我多选行然后使用此代码,当我在sql表中检查结果时,我发现此代码只考虑datagridview中的第一个选定行而忽略其余行。 这太正常了,因为在每次迭代中都使用与 DGV.SelectedRows[0] 相同的行单元格,而不是您迭代的行。 改变你的 OrderNumber = Convert.ToInt32(DGV.SelectedRows[0].Cells[0].Value); OrderDateTime = Convert.ToDateTime(DGV.SelectedRows[0].Cells[4]. ... -
在第一个代码示例中,每次迭代都会创建一个新的SqlCommand : SqlCommand command = new SqlCommand(insertQuery, connection); 在第二个中,所有迭代都修改相同的命令,添加越来越多的参数。 只有第一个调用具有正确数量的参数,下一个调用具有太多参数。 在没有值的循环之前添加参数,然后在循环中设置值并执行命令 command.Connection = connection; command.CommandType = CommandType.St ...
-
内联查询和存储过程的相同查询的不同执行(Different execution of the same query for Inline query and a stored procedure)[2021-06-12]
最后我得到了解决方案。实际上问题是,在内联查询执行期间,行被限制为50000,因此它很容易显示所有行,但例程(存储过程)实际上是试图返回所有(16,000 * 16,000) MySQL工作台无法显示的行。因此,在执行存储过程期间,获取时间过长,这就是为什么它强制关闭的原因。 抱歉张贴错误的问题,并抱歉,如果我通过发布这个问题误导了你们任何一个。 无论如何谢谢你们。 Finally I got the solution.Actually the problem was that during the inl ... -
C# - 循环foreach直到真(C# - Loop foreach until true)[2023-01-20]
您使用while循环的想法应该可行。 你可以尝试这样的事情: IntPtr hWnd = IntPtr.Zero; bool isFound = false; while(!isFound) { foreach (Process procList in Process.GetProcess()) { if (procList.MainWindowTitle.Contains("SAP Logon")) { isFound = true; hWnd = ... -
在c#中使用存储过程(Use stored procedure in c# ef)[2023-11-10]
“不起作用”是什么意思? 您是否收到编译错误,运行时异常或只是意外的结果? 请在aska问题时始终指定。 什么是SPLogCountInUser方法的返回类型? 如果它是一个IEnumerable ,那么可以将Label的Content属性设置为第一项的字符串表示形式: HadishDataBaseEntities database = new HadishDataBaseEntities(); var All = database.SPLogCountInUser(HadishCode.gUserID). ... -
存储过程循环(Stored Procedure Loop)[2022-12-09]
如果您确实无法更改存储过程,则可以使用游标创建循环。 除非绝对必要,否则我不会建议这个行动方案。 declare c cursor local read_only for select property_component_id from propertiestable declare @id open c fetch from c into @id while @@fetch_status=0 begin EXEC @return_value = [dbo].[p_CPGUploade ... -
也许db填充values调用已经打开了一个事务,阻止了内部调用的运行。 尝试在填充values的调用中使用.ToList()来预先加载所有值。 Perhaps the db call to populate values has opened a transaction, stopping the inside call functioning. Try using .ToList() in the call that populates values to preload all of the value ...
-
不要在循环中执行那些SQL查询。 将它们组合在一个SQL语句中: $sql = 'SELECT a.konto_odbiorcy, a.nazwa, a.miasto, a.zip_code, a.ulica , max(e1.date) as date_le_curdate , min(e2.date) as date_ge_curdate FROM klienci_ax_all as a LEFT JOIN 3ce_event as e1 ON (a.konto_odbiorcy=e1.number A ...
-
它失败的原因是你将参数传递给CREATE PROC部分: cmd.CommandText = @"CREATE PROC #AddCriteriaTable (@ParameterCode VARCHAR(64), @Value VARCHAR(64)) AS INSERT #CriteriaTable VALUES (@ParameterCode, @Value)"; cmd.Parameters.AddWithValue("@ParameterCode", request.Criteria.First( ...
-
使用在循环中设置为true的布尔变量。 为简单起见,删除了不相关的代码: DECLARE found boolean default false; ... REPEAT FETCH loop_cur ... SET found = true; ... UNTIL done END REPEAT; -- found is now true if you got some rows, false otherwise Use a boolean variable that ...