PDA

View Full Version : سوال: sql connectiion



oldboy
دوشنبه 03 فروردین 1388, 20:04 عصر
سلام.
من تو کار با پایگاه داده تازه کارم. وقتی تو برنامه ای میخوام با sql ارتباط برقرار کنم خطای زیر رو می ده.هر چی به فکرم رسید انجام دادم ولی به نتیجه ای نرسیدم. ممنون میشم اگه کمکم کنید.:ناراحت:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

siavash_realy
دوشنبه 03 فروردین 1388, 21:49 عصر
لطفا Connection String خودتون رو هم بگيد

AminSobati
سه شنبه 04 فروردین 1388, 01:29 صبح
دوست عزیزم احتمالا SQL Server Developer Edition نصب کردین و در شبکه قصد Connect شدن دارین. آیا اینطوره؟

oldboy
سه شنبه 04 فروردین 1388, 13:29 عصر
سلام.
نه به شبکه متصل نمی شم.

connection string:

SqlConnection objConnection = new SqlConnection
("Server=localhost; Database=club;User ID=mohsen;Password=5247440;");

بالای برنامه هم نوشتم:
using System.Data.SqlClient;

siavash_realy
سه شنبه 04 فروردین 1388, 14:36 عصر
اين چند تا راه رو تست كن ببين جواب ميده يا نه، اما قبل از هرچير مطمئن شو سرويس SQL تو درحال اجرا باشه ، چون احتمال داره اين سرويس روي كامپيوترت stop شده باشه (برو تو run و تايپ كن : services.msc و چك كن ببين سرويس هاي SQL ات هم Enable باشن و هم Start خورده باشن) اگر اينطور بودن و باز هم مشكل داشتي راه هاي زير رو تست كن :

Solution 1:

Go to, Start >> Programs >> Microsoft SQL Server 2005 >> Configuration
Tools >> SQL Server 2005 Surface Area Configuration >> Surface Area
Configuration for Services and connections.

Within this check whether "Local and remote connections" is choosen.
If not choose it :)

- Open the "SQL Server Configuration Manager" (under Configuration Tools)
- Expand the "SQL Server 2005 Network Configuration"
- Select the "Protocols for "
- Set the Named Pipes To Enabled

SOLUTION 2:

1. Click Start, click Run, type cliconfg, and then click OK.
2. In the SQL Server Client Network Utility dialog box, click the Alias tab, and then click Add.
3. In the Add Network Library Configuration dialog box, under Network libraries, click TCP/IP.
4. In the Server alias box, type the IP address of the computer or the
name of the computer that is running SQL Server, and then click OK.

SOLUTIONS 3:

Enable the TCP/IP protocol using the Surface Area Configuration Utility
Make sure the TCP/IP protocol is enabled in the SQL Server Configuration Utility
Make sure the SQL Server browser is started. Note this step is optional. It is possible to set the SQL Server instance to use a fixed IP address - but this is non-standard for named instances
Make sure SQL Server and SQL Server Browser are exempted by the firewall on the server machine. This is done by putting sqlservr.exe and sqlbrowser.exe as an exception in the windows firewall.
Note: In order to get things to work. You might need to completely reboot the server machine after making the changes. There have been reports that starting and stopping the SQL Server and Browser software is not enough.

siavash_realy
سه شنبه 04 فروردین 1388, 14:38 عصر
درضمن شايد بد نباشه تو محيط IDE اس كيو ال 2005 ، يك بار هم روي سرورت رايت كليك كني و اون رو Restart كني و بعد از چند دقيقه تست كني ببيني مشكلت حل شده يا نه !

elmira_63
شنبه 05 اردیبهشت 1388, 08:36 صبح
سلام دوستان
من هم دقیقا همین مشکل رو دارم رفتم توی services اصلا سرویس های sql2005 ام توش نبود که بخواد run باشه یا نباشه و اون کارای دیگه رو هم انجام دادم که گفته بودید ولی یا باز نمی شد یا این که یه پیغام میداد که شما نمی تونید کانکت بشید یا که ادمین نیستید در صورتی که ویندوزم با ادمین بالا اومدم؟؟؟؟؟؟؟؟؟

mom alone
شنبه 05 اردیبهشت 1388, 18:03 عصر
میگم مطمئن هستی که نام سرور رو درست میدی؟
از "." و یا "(local)"
استفاده کن ببین چجور میشه

mahsa_999
چهارشنبه 13 خرداد 1388, 19:46 عصر
سلام
منم همین مشکل رو داشتم. این راه حل رو امتحان کن:
روی سرور راست کلیک کن و properties رو انتخاب کن. از قسمت select the page صفحه security رو انتخاب کن. و در نهایت: Server authentication-> SQL and Windows Authentication Mode

البته این در صورتی جواب می ده که با windows authentication بتونی connect کنی

در ضمن در SQLSERVER Configuration Manager چک کن که Named pipes و TCP/IP حتما Enable باشه

mahsa_999
چهارشنبه 13 خرداد 1388, 20:01 عصر
سلام.
نه به شبکه متصل نمی شم.

connection string:

SqlConnection objConnection = new SqlConnection
("Server=localhost; Database=club;User ID=mohsen;Password=5247440;");

بالای برنامه هم نوشتم:
using System.Data.SqlClient;


روی سرور راست کلیک کن و properties رو انتخاب کن. از قسمت select the page صفحه security رو انتخاب کن. و در نهایت: Server authentication-> SQL and Windows Authentication Mode

بعد می تونی یک user تو قسمت logins بسازی و با connection string رو اینطوری تنظیم کنی:
" Data Source=.\\sqlexpress; Database=test; User ID=yourID; Password=yourpass"
یا اگه می خوای با windows authentication وصل شی:
" Data Source=.\\sqlexpress; Database=test; integrated security=true"

http://kbase.gfi.com/showarticle.asp?id=KBID002804