问题:使用LINQ Classes连接到c#中的数据库 [英] problem : connection to database in c# with LINQ Classes

查看:60
本文介绍了问题:使用LINQ Classes连接到c#中的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨开发人员和程序员,



i用c创建电话簿软件

i用Visual Studio 2012创建数据库

和我连接LINQ Classes [LINQ to SQL Classes]



当我在我的电脑上使用时,我的软件非常适合工作/>
但是当我在另一台电脑上使用时,他们会收到一些错误



i被编辑为app.config



来自:


[code]



< configuration>

< configsections>



< connectionstrings>

< add name =test.Properties.Settings.testingConnectionString >

connectionString =Data Source =(localdb)\Projects; Initial Catalog = test-db; Integrated Security = True

providerName =System.Data .SqlClient/>

< add name =test.Properties.Settings.testingConnectionSt ring1>

connectionString =Data Source =(localdb)\Projects; Initial Catalog = test-db; Integrated Security = True

providerName =System。 Data.SqlClient/>





[/ code]



to



[code]



< configuration>

< ; configsections>



< connectionstrings>

< add name =test.Properties.Settings.testingConnectionString>

connectionString =Data Source = | DataDirectory |; Initial Catalog = test-db; Integrated Security = True

providerName =System.Data.SqlClient/>

< add name =test.Properties.Settings.testingConnectionString1>

connectionString =Data Source = | DataDirectory |; Initial Catalog = test-db; Integrated Security = True

providerName =System.Data.SqlClient/>





[/ code]





截屏和错误消息:



[img] http://s1.picofile.com/file/7906626769/Capture.png [/ img]



[code]

有关调用

实时(JIT)调试而不是此对话框的详细信息,请参阅此消息的结尾盒子。





**************例外文字******** ******

System.Data.SqlClient.SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:命名管道提供程序,错误:40 - 无法打开与SQL Server的连接)---> System.ComponentModel.Win32Exception(0x80004005):找不到网络路径

.....





************** JIT调试**************

启用实时(JIT)调试时,这个

应用程序或计算机(machine.config)的.config文件必须在system.windows.forms部分设置

jitDebugging值。

应用程序也必须通过调试编译

启用。



...........

[/ code]





请帮帮我,谢谢

Hi developers and programmers,

i was create a phone book software with c#
i was create a database with Visual Studio 2012
and i was conneted with LINQ Classes [LINQ to SQL Classes]

when i use in my computer , my software is perfect for working
but when i use in another computers , they have get something error

i was edited app.config

from :

[code]

<configuration>
<configsections>

<connectionstrings>
<add name="test.Properties.Settings.testingConnectionString">
connectionString="Data Source=(localdb)\Projects;Initial Catalog=test-db;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="test.Properties.Settings.testingConnectionString1">
connectionString="Data Source=(localdb)\Projects;Initial Catalog=test-db;Integrated Security=True"
providerName="System.Data.SqlClient" />


[/code]

to

[code]

<configuration>
<configsections>

<connectionstrings>
<add name="test.Properties.Settings.testingConnectionString">
connectionString="Data Source=|DataDirectory|;Initial Catalog=test-db;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="test.Properties.Settings.testingConnectionString1">
connectionString="Data Source=|DataDirectory|;Initial Catalog=test-db;Integrated Security=True"
providerName="System.Data.SqlClient" />


[/code]


Screen shot and error messages :

[img]http://s1.picofile.com/file/7906626769/Capture.png[/img]

[code]
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.


************** Exception Text **************
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
.....


************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

...........
[/code]


please help me , thanks

推荐答案

如果您认为您的连接字符串是完美的并且它没有问题并且它在您的系统上正常工作,那么您应该查看使用连接字符串连接到数据库的LINQ代码。有时,它会对连接字符串进行硬编码,因为应用程序停止在其他系统上运行。如果仍然没有错,那么您可以使用远程调试器来调试代码以了解出现了什么问题。远程调试器附带visual studio。
If you think that your connection string is perfect and it has no issue and it works properly on your system then you should look at the LINQ code which is using the connection-string for connection to the database. Sometimes, it hard-code the connection string due to which the application stops working on other systems. If there is still nothing wrong, then you can use the remote-debugger to debug your code to get to know what is going wrong. Remote debugger comes with visual studio.


Hi Ram,



请查看 您的解决方案 [ ^ ]
Hi Ram,

Please look into Your Solution[^]


这篇关于问题:使用LINQ Classes连接到c#中的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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