PDA

View Full Version : سوال: اتصال به دیتابیس webconfing



saeed-71
پنج شنبه 16 خرداد 1392, 16:12 عصر
سلام.
چجوری میشه به دیتا بیس وصل شد؟
چه دستوری باید نوشت؟
میخوام رو هر سیستمی که دیتابیس اتچ شد جواب بده.
اسم دیتابیسم w1 هستش
تو sql managment ساختمش.

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="false">
<assemblies>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>

forestasphalt
پنج شنبه 16 خرداد 1392, 16:50 عصر
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\DbProduct.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />

<connectionStrings>
<add name="ConnStringDb1" connectionString="Data Source=localhost;Initial Catalog=YourDataBaseName;Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
به خاطر متفاوت بودن نسخه های sql و instance ها هیچ راهی وجود نداره با یک کانکشن استرینگ بتونی توی تمام سیستم ها بیاد
connectionStrings اول از نسخه sql express استفاده میکنه که این کانکشن هم توی تمام سیستم ها نمیاد
به نظرم بهترین کار اینه که از دیتابیس ها اسکریپت تهیه کنید اون اسکریپت رو به اشخاص مورد نظر بدید تا باز کنند

saeed-71
پنج شنبه 16 خرداد 1392, 17:18 عصر
این کانکشن استرینگ کجاش مشکل داره؟

SqlConnection con = new SqlConnection("Data Source=Data Source=SAEED-PC\SQLEXPRESS;Initial Catalog=w1;Integrated Security=True");

دقیقا ادرس دیتابیس من هستش اما ارور میده

forestasphalt
پنج شنبه 16 خرداد 1392, 17:45 عصر
2 دفعه از کلمه Data Source استفاده کردی

saeed-71
پنج شنبه 16 خرداد 1392, 17:46 عصر
مشکل کانکشن استرینگم درست شده
حالا web.config مشکل داره.چجوری درستش کنم؟چیو توش تغییر بدم؟

forestasphalt
پنج شنبه 16 خرداد 1392, 20:49 عصر
چه خطایی میده؟کل وب کانفینگ رو بذار