问题描述
您好,
我想问一下如何在WorkflowConsoleApplication中使用在SQL Server 2005中创建的数据库获取连接。
我正在尝试使用这些命令行,但它不起作用。
在Program.cs中:
Hello,
I would like to ask how to get connection in WorkflowConsoleApplication with database which is created in SQL Server 2005.
I am trying with these command line but its do not work.
In Program.cs:
const string connString = "Initial Catalog=kino;Data Source=CHACH-KOMPUTER\\SQLEXPRESS;Integrated Security=SSPI;";
workflowRuntime.AddService(new SqlWorkflowPersistenceService(connString));
在Workflow.cs中:
In Workflow.cs:
string conn = ".;DATABASE=kino;Integrated Security=SSPI;";
我会很高兴得到任何答案和线索。
提前谢谢。
I will be greatful for any answers and clues.
Thanks in advance.
推荐答案
SqlConnection conn = new SqlConnection(connString);
conn.open();
conn.close();
如果上面的代码抛出异常,那么它确实是你的连接字符串。您可以尝试自行修复或查看本文以获取更多信息。
[]
但是如果你能够连接到数据库,那么问题出在 workflowRuntime 对象中。如果您发布有关您所获得的异常的更多详细信息,我相信有人可以为您提供更多帮助。
If the above code throws an exception then indeed it is your connection string. You can try to fix it yourself or have a look at this article for more information.
http://msdn.microsoft.com/en-us/library/ms254947.aspx[^]
However if you are able to connect to the database, then the problem lies within the workflowRuntime object. If you post more details on the exception that you are getting I am sure some one will be able to help you further.
这篇关于连接到数据库 - MS Visual Studio 2012到MS SQL Server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!