PDA

View Full Version : error : A network-related or instance-specific error occurred while establishing a connection to SQL



behnam007
دوشنبه 04 فروردین 1393, 16:02 عصر
سلام ، من وقتی میخوام با دیتابیس کار کنم(مثلا رکورد ها رو بخونم و..) با این 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)

connectionstring هم درسته ؟ در ضمن من از vs 2012 استفاده می کنم.
به نظر شما مشکل از کجاست ؟

fakhravari
دوشنبه 04 فروردین 1393, 17:17 عصر
تایم اوت کانکشت باید زیاد کنید

behnam007
دوشنبه 04 فروردین 1393, 18:04 عصر
چه جوری تایم اوت رو زیاد کنم (من تازه کارم) ؟

mehdi1359a
دوشنبه 04 فروردین 1393, 18:06 عصر
دوست عزیز یه نگاه یه سرویس های sql بنداز ببین start هستند؟ اول چک کن ببین از sql می تونی به بانکت وصل شی؟ممکنه سرویهای sql متوقف شده باشند که باید استارتشون کنی

behnam007
دوشنبه 04 فروردین 1393, 18:22 عصر
چجوری راهنمایی بفرمایید :افسرده:

imohsen
دوشنبه 04 فروردین 1393, 20:29 عصر
سلام ، من وقتی میخوام با دیتابیس کار کنم(مثلا رکورد ها رو بخونم و..) با این 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)

connectionstring هم درسته ؟ در ضمن من از vs 2012 استفاده می کنم.
به نظر شما مشکل از کجاست ؟

باید بگی چه موقع این خطا رو میده؟ موقع بازیابی، حذف، درج، آپدیت.....
ضمنا در حالت کلی یک بار دیگه از قسمت server explorer در ویژوال استادیو یک کانکشن جدید به بانکت بساز و از دکمه Test Connection رو بزن تا مطمئن شی و در ضمن در فایل web.config چک کن و connection string های اضافی رو حذف کن.

behnam007
دوشنبه 04 فروردین 1393, 21:30 عصر
هم موقع حذف و درج و بازیابی و ...
Test Connection هم درست هست.اما مثلا تو کد زیر از con.open() همون خطا رو میگیره :


SqlConnection con = new SqlConnection();
con.ConnectionString = System.Configuration.ConfigurationManager.Connecti onStrings["co2"].ConnectionString;
con.Open();

behnam007
سه شنبه 05 فروردین 1393, 06:38 صبح
یک سوال دیگه : مسیر SQL Server Configuration Manager کجا هست ؟من از SQL Server 2012 express استفاده میکنم.و در این مسیر هم Configuration Manager نیست :


C:\Program Files\Microsoft SQL Server\110\Tools\Binn

imohsen
پنج شنبه 07 فروردین 1393, 08:11 صبح
ببین من خودم یه متد بصورت مجزا در یک کلاس درست کردم و از اون استفاده می کنم، با این تست کن ببین جواب میگیری:

public static DataTable GetTableDataFromDB(string CMDText)
{
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrin gs["YourConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = CMDText;
connection.Open();
DataTable result = new DataTable();
result.Load(command.ExecuteReader());

connection.Close();
return result;
}