我该如何解决这个问题 [英] How do I fix this problem

查看:64
本文介绍了我该如何解决这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在aws上安装了我的项目及其工作正常,但是当我插入一些数据时,它会显示一些连接错误。它无法连接到数据库。



我插入即时报警时出现以下错误:



A建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:SQL网络接口,错误:26 - 查找指定服务器/实例时出错)



错误是在线号码:54



第52行:cmd.Parameters.AddWithValue(@ hint,txthint.Text.Trim());

第53行:cmd.Connection = con;

第54行:con.Open();

第55行:userid = Convert.ToInt32(cmd.ExecuteScalar());

第56行: con.Close();



我尝试过:



i我已经尝试了google和youtube中提供的每个解决方案来解决这个问题,但我的问题仍然存在但尚未解决。

i have hosted my project on the aws and its working good,but when im inserting some data that time it will showing some connection error. it is failing to connect to the database.

while im inserting im getting below error:

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

the erron is on line no:54

Line 52: cmd.Parameters.AddWithValue("@hint", txthint.Text.Trim());
Line 53: cmd.Connection = con;
Line 54: con.Open();
Line 55: userid = Convert.ToInt32(cmd.ExecuteScalar());
Line 56: con.Close();

What I have tried:

i have tried each and every solution given in google and youtube to fix this issue but my issue is remains same and it not solved yet.

推荐答案

使用调试器,看看正好在连接字符串中设置 con 使用 - 然后从你的电脑上检查它以确保它是好的。

我们不能为您做到这一点 - 我们无法访问您的数据库服务器,甚至是从哪里加载连接字符串的想法!

如果你不能在运行该代码的实际机器上使用调试器,那么添加日志语句以将数据保存到文件中,发生错误后查看它。

您可能指定了错误的服务器,或者您执行代码的计算机无法访问的服务器。
Use the debugger, and look at exactly what is in the connection string to set up con to use - and then check that from your PC to make sure it's good.
We can't do that for you - we don't have access to your DB server, or even any idea where you load the connection string from!
If you can't use a debugger on the actual machine running that code, then add logging statements to save the data to a file, and look at it after the error has occurred.
The chances are that you are specifying the wrong server, or a server that the machine you execute the code on can't reach.


这篇关于我该如何解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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