本文介绍了C# - 连接到MDF数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 当我的代码执行我要求它执行的查询时,我总是遇到错误,我确定这是由于以下代码:I''m always having a error while my code executes the query I ask it to do, and I''m sure it''s due to the following code:public SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=" + System.IO.Path.GetFullPath("cybercafe.mdf") + ";Integrated Security=True;Connect Timeout=30;User Instance=True"); 不幸的是我不喜欢不知道它有什么问题。 如果有人有解决方法连接到在服务器资源管理器中创建的MDF数据库,请随时提供反馈。 谢谢。Unfortunately I don''t know what is wrong with it.If anyone has a workaround to connect to a MDF database created in the Server Explorer, feel free to give feedback.Thanks.推荐答案<connectionStrings> <add name="MyConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Book.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings> 但你最好使用Sql Server (epxress),SQL Management Studio,附加数据库并使用它的名称而不是文件路径。But you better use Sql Server (epxress), SQL Management Studio, attach the database and use it''s name rather than the file path. 这篇关于C# - 连接到MDF数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-13 15:32