PDA

View Full Version : سوال: نحوه ساخت connection string



hosein31o
جمعه 29 آذر 1387, 22:57 عصر
با سلام من هنگام کار با sql server 2005 تو c# برای ایجاد connection string مشکل دارم یا بهتره بگم connection string را دارم ولی موقعی که برنامه می خواد اجرا بشه این پیغام خطا رو میده :

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

در ضمن sql server 2005 هم Run هست برای همینه که نمیدونم اشکال از کجاست . اینم connection string که استفاده می کنم :


SqlConnection objsqlconnnection = new SqlConnection("server=localhost;database=anbar_db;user id=sa");
ممنون میشم منو راهنمایی کنین قبلا با sql server 2000 این مشکلو نداشتم !!!

r_mehrizi
شنبه 30 آذر 1387, 08:40 صبح
اگه شما با sqlexpress كار مي كنيد بايد به اين صورت بنويسيد


<connectionStrings>
<add name="OGHAFConnectionString" connectionString="Data Source=(local)\sqlexpress;Initial Catalog=oghaf;integrated security=true"
providerName="System.Data.SqlClient" />
</connectionStrings>

hosein31o
شنبه 30 آذر 1387, 22:22 عصر
خیلی از راهنمایی شما متشکرم ولی بی زحمت برای اطلاعات خورم می خوام بدونم که sqlexpress چه فرقی میکنه ؟