• 1398/06/03

connection string :

با سلام و عرض ادب

چندتا سوال ؟؟

1- من نمی خوام پایگاه داده که در sql server درست کرده ام انتقال بدم به پایگاه داده express در این صورت رشته اتصال به چه صورت خواهد شد؟

2- برای ارتباط به پایگاه داده حتما باید در ویندوز مقصد sql server نصب باشه درسته؟

3- چطور میشه موقعی که فایل ستاپ نصب میشه به صورت مستقیم پایگاه داده که کنار برنامه وجود داره به sql server مقصد اضافه شود؟ و برنامه کار کند.؟

رشته اتصال را به صورت زیر تغییر دادم

 

 

  <connectionStrings>

 

  <connectionStrings>
 <add name="Accounting_DBEntities" connectionString="metadata=res://*/AccountingModel.csdl|res://*/AccountingModel.ssdl|res://*/AccountingModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;AttachDbFilename=|DataDirectory|\Accounting_DB.MDF;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

داخل پوشه debug اصلی برنامه ام ،

فایل پایگاه داده را کنار فایل exe برنامه قرار دادم
و دو فایل  به نام های Accounting.App.exe.config  و Accounting.App.vshost.exe.config را که رشته اتصال داخلش بود به رشته اتصال بالا تغییر دادم.

اما پیغام میده که که نمی تونه پایگاه داده را پیدا کنه

 

محبت میکنید پاسخ بدید
با تشکر

  • 1398/06/03
  • ساعت 12:24

سلام 

آموزش ساخت ستاپ در سایت را ببینید 


  • 1398/06/05
  • ساعت 00:08

با سلام مجدد
استاد ببخشید
من دقیقا طبق آموزش ستاپ گیری انجام میدم

SQL.Server.2016.Enterprise.x64
, Microsoft.SQL.Server.2016.Express.Advanced.x64
رو سیستم خودم نصب هست
ابتدا از دیتابیس اصلی یک Generate Scripts تهیه کردم
(Script for Server Version : sql server 2016   ,  type of data  to Script : Schema and data)

بعد با نوشتن .\sqlexpress به پایگاه داده express وصل شدم
یک دیتابیس به همون نام ایجاد و دستورات Script ساخته شده را از Create به بعد داخلش اجرا کردم و جداول ام به دیتابیس اضافه شد.

دیتابیس ساخته شده روی Detath کردم و کنار فایل اجرای برنامه گذاشتم
هر دو فایل دیتابیس را تنظیم سطح دسترسی Full Control برای تمام یوز ها کردم.
رشته Connection String  را به صورت خودتان تغییر دادم
فایل نمونه شما:

 

<add name="PUBSEntities" connectionString="metadata=res://*/Models.Pubs.csdl|res://*/Models.Pubs.ssdl|res://*/Models.Pubs.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Bashgah100Data.MDF;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />


فایل من با تغییرات
 

<add name="Accounting_DBEntities" connectionString="metadata=res://*/AccountingModel.csdl|res://*/AccountingModel.ssdl|res://*/AccountingModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Accounting_DB.MDF;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
     

طبق آموزش ستاپ گیری تون باید قبل از ستاپ گیری با تغییر رشته اتصال به sqlexpress
امدم و دیتابیس را از sqlserver و sqlexperss پاک کردم
الان باید با اجرای فایل پروژه،  پروژه اجرا بشه اما خطای زیر را میده که میگه نمی تونه دیتبابیس را پیدا کنه



می دونم سرتون شلوغه ولی خواهشا لطفا یه راهنمایی کامل بفرمایید


  • 1398/06/05
  • ساعت 10:50

استاد سلام
یه راهنمایی بفرمایی
لطفا


  • 1398/06/05
  • ساعت 10:57

detail خطا رو مطالعه کنید توضیحات بیشتری در اونجا هست 


  • 1398/06/05
  • ساعت 11:14

 

استاد متن کامل خطا
چیزی جز عدم اتصال متوجه نشدم!!!
 


See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

 

************** Exception Text **************
System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<Open>b__36(DbConnection t, DbConnectionInterceptionContext c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Core.EntityClient.EntityConnection.<Open>b__2()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Accounting.DataLayer.Services.GenericRepository`1.Get(Expression`1 where) in F:\fradars\C#projection\top lern c#\Accounting\Accounting.DataLayer\Services\GenericRepository.cs:line 28
   at Accounting.App.frmLogin.btnLogin_Click(Object sender, EventArgs e) in F:\fradars\C#projection\top lern c#\Accounting\Accounting.App\frmLogin.cs:line 39
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

 
************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Accounting.App
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/fradars/C%23projection/top%20lern%20c%23/Accounting/Accounting.App/bin/Debug/Accounting.App.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accounting.DataLayer
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/fradars/C%23projection/top%20lern%20c%23/Accounting/Accounting.App/bin/Debug/Accounting.DataLayer.DLL
----------------------------------------
Accounting.Utility
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/fradars/C%23projection/top%20lern%20c%23/Accounting/Accounting.App/bin/Debug/Accounting.Utility.DLL
----------------------------------------
EntityFramework
    Assembly Version: 6.0.0.0
    Win32 Version: 6.1.40302.0
    CodeBase: file:///F:/fradars/C%23projection/top%20lern%20c%23/Accounting/Accounting.App/bin/Debug/EntityFramework.DLL
----------------------------------------
System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
EntityFramework.SqlServer
    Assembly Version: 6.0.0.0
    Win32 Version: 6.1.40302.0
    CodeBase: file:///F:/fradars/C%23projection/top%20lern%20c%23/Accounting/Accounting.App/bin/Debug/EntityFramework.SqlServer.DLL
----------------------------------------
Anonymously Hosted DynamicMethods Assembly
    Assembly Version: 0.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/mscorlib/v4.0_4.0.0.0__b77a5c561934e089/mscorlib.dll
----------------------------------------
System.Numerics
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
System.Data.OracleClient
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data.OracleClient/v4.0_4.0.0.0__b77a5c561934e089/System.Data.OracleClient.dll
----------------------------------------
System.Transactions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
Accounting.ViewModel
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/fradars/C%23projection/top%20lern%20c%23/Accounting/Accounting.App/bin/Debug/Accounting.ViewModel.DLL
----------------------------------------
Stimulsoft.Report
    Assembly Version: 2010.1.700.0
    Win32 Version: 2010.1.700.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Stimulsoft.Report/2010.1.700.0__ebe6666cba19647a/Stimulsoft.Report.dll
----------------------------------------
Accounting.Business
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/fradars/C%23projection/top%20lern%20c%23/Accounting/Accounting.App/bin/Debug/Accounting.Business.DLL
----------------------------------------
Stimulsoft.Base
    Assembly Version: 2010.1.700.0
    Win32 Version: 2010.1.700.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Stimulsoft.Base/2010.1.700.0__ebe6666cba19647a/Stimulsoft.Base.dll
----------------------------------------
System.Xml.Linq
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1590.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------

 

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

 

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

 

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

  • 1398/06/05
  • ساعت 12:09

یه چیز به این کوچکی اینقدر اذیت میکنه چرا !!!!
از سایت https://www.connectionstrings.com/sql-server-2005/ روش های آدرس دهی مطلق و نسب را هم امتحان کردم _ درست نشد
چهار روز تمام باهاش درگیرم باید درستش کنم ولی حال دیگه کلافه ام کرده

استاد ربطی به Script for Server Version : sql server 2016 نداره  ؟  چون خودتان هم گفته بودید باید همون express باشه که رو سیستم مقصد نصب هست منم sql server 2016 را انتخاب کردم
 


  • 1398/06/05
  • ساعت 12:11

بله ورژن باید یکی باشه 

 


  • 1398/06/05
  • ساعت 12:14

به خدا استاد یکجور هست
نمی دونم کجای کارم ایراد داره
از متن خطا هم چیزی نفهمیدم
شما پیشنهادی دیگه ای ندارید؟


  • 1398/06/05
  • ساعت 12:15

خیر متاسفانه 

ساخت ستاپ همیشه برای ما برنامه نویس ها کابوس بوده 

مستندات Install Aware را مطالعه کنید یا از Install Shield استفاده کنید 


  • 1398/06/05
  • ساعت 12:22

استاد از اینکه وقت گذاشتید و با حوصله جواب می دید یه دنیا ممنونم  

ولی من هنوز به مرحله ستاپ گیری ایش نرسیده ام
 باید قبل از ستاپ گیری رو سیستم خودم یه تست بکنم با رشته اتصال که تغییر دادم تو این مرحله جواب نمی گیرم

 


logo-enamadlogo-samandehi