是否可以使用.Net框架从SQL数据库接收SELECT或Procedure Execution进度? 无论何时在SSMS中选择大数据,它都会显示执行进度,我的意思是它会给你+ = 500 - 500行。我可以在WinForm项目中使用它吗?
答案 0 :(得分:2)
使用ADO.NET / SQL Server完成此操作非常简单。您可以简单地将事件挂钩到from path.to.models import Venue
admin.site.register(Venue)
,如下所示:
SqlInfoMessageEventHandler
如果要执行多个语句,在SQL语句/存储过程中,您可以选择报告这些语句的状态,即
{
SqlConnection sqlConnection = new SqlConnection(“................”);
sqlConnection.Open();
sqlConnection.InfoMessage += new SqlInfoMessageEventHandler(ProgressStatus);
// Execute your long running query here
}
private void ProgressStatus(object sender, SqlInfoMessageEventArgs e)
{
if (e.Errors.Count > 0)
{
string message = e.Errors[0].Message;
int state = e.Errors[0].State;
// Set status of the progress bar
// progressBar1.Value = state;
}
}
SELECT ............ FROM .......... INNER JOIN ............. INNER JOIN ............
RAISERROR('Message',10,25) WITH NOWAIT
SELECT ............ FROM .......... INNER JOIN ............. INNER JOIN ............
RAISERROR('Message',10,50) WITH NOWAIT
SELECT ............ FROM .......... INNER JOIN ............. INNER JOIN ............
RAISERROR('Message',10,75) WITH NOWAIT
SELECT ............ FROM .......... INNER JOIN ............. INNER JOIN ............
RAISERROR('Message',10,100) WITH NOWAIT
选项会强制将消息立即传递给客户端,而不是等到一切都完成后再进行。