连接到数据库 - MS Visual Studio 2012到MS SQL Server 2005 [英] Connection to database - MS Visual Studio 2012 to MS SQL Server 2005

查看:117
本文介绍了连接到数据库 - MS Visual Studio 2012到MS SQL Server 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想问一下如何在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.

推荐答案

问题很可能与您的连接字符串有关。您可以通过尝试连接到数据库来检查它

The problem is most likely related to your connection string. You can check for that by trying to connect to the database
SqlConnection conn = new SqlConnection(connString);
conn.open();
conn.close();



如果上面的代码抛出异常,那么它确实是你的连接字符串。您可以尝试自行修复或查看本文以获取更多信息。



http://msdn.microsoft.com/en-us/library/ms254947.aspx [ ^ ]



但是如果你能够连接到数据库,那么问题出在 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.


确实,代码会引发异常:



故障排除异常:System.Data.SqlClient.SqlException



在行中:

WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication4.Workflow1));



>>>找不到存储过程''RetrieveNonblockingInstanceStateIds''。 />


我不确定,因为我不记得了(我在ppast中做了一些项目)但是我脑子里有一盏明灯,也许这就是这行中的反斜杠:



const string connString =初始目录= kino;数据源= CHACH-KOMPUTER \\SQLEXPRESS;集成安全性= SSPI;;



或其他非常容易修复的东西,但现在我无法弄明白。



我会在它开始讨厌之前继续挖掘。
Yes indeed, the code throws me an exception:

Troubleshooting Exceptions: System.Data.SqlClient.SqlException

In the line:
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication4.Workflow1));

>>>Could not find stored procedure ''RetrieveNonblockingInstanceStateIds''.

I am not sure because do not remember (I did some project in the ppast) but I have a light in my head and maybe it is something with the backslash in this line:

const string connString = "Initial Catalog=kino;Data Source=CHACH-KOMPUTER\\SQLEXPRESS;Integrated Security=SSPI;";

or something else which is very simple to fix but for now I can not figure it out.

I will keep digging before it starts annoying.


这篇关于连接到数据库 - MS Visual Studio 2012到MS SQL Server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆