View Full Version : مبتدی: خواندن connection string از webconfig
royalreihaneh
سه شنبه 06 تیر 1391, 15:37 عصر
سلام من می خوام connection string را از web config بخونم ولی کد های زیر رو که می نویسم اشکال می گیره
string connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
به هیچ عنوان configurationmanager رو نمی شناسه حتی تو using namespace هم نمیشناسه
دارم تو asp .netn ld k,dsl
mehrzad_ali
سه شنبه 06 تیر 1391, 16:09 عصر
Add a reference to System.Configuration by clicking Project -> Add Reference... and searching through the .NET components for System.Configuration
royalreihaneh
سه شنبه 06 تیر 1391, 19:11 عصر
bebinid system.configuration ro add kardam configuration manager ro nemishnase
royalreihaneh
سه شنبه 06 تیر 1391, 19:12 عصر
Add a reference to System.Configuration by clicking Project -> Add Reference... and searching through the .NET components for System.Configuration
bebinid system.configuration ro add kardam configuration manager ro nemishnase
sasanrstm
پنج شنبه 08 تیر 1391, 01:16 صبح
شما بايد using system .web .configuration رو اضافه كنيد به فضاي نام و تو configuration
<appSettings/>
<connectionStrings>
<add name="MainConnStr" providerName="System.Data.SqlClient" connectionString=" كانكشن خودتون رو بزاريد"></add>
</connectionStrings>
<system.web>
sasanrstm
پنج شنبه 08 تیر 1391, 01:22 صبح
وكد تو اينجوري بزار تو هر صفحه اي كه خواستي
string connStr =webConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString
موفق باشي
zahramehdi
پنج شنبه 08 تیر 1391, 12:39 عصر
سلام
من یه مشکلی تو صفحه آپلود شدم در سایتم دارم که باید دادههاشو ابید از دیتابیس sql بخونه ولی این error را میدهد ممکن راهنمایی کنید؟
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File --><configuration> <system.web> <customErrors mode="Off"/> </system.web></configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File --><configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web></configuration>
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.