Click here to Skip to main content
12,072,067 members (63,398 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# SQL LINQ
Hello friends,
I created a Service based MDF file in Visual studio, and connect it to a Linq dbml file. but i get this error, before i didn't see this.

the error is in here:

public LINQDataContext() :
                base(global::Language_Learning_Application.Properties.Settings.Default.Database1ConnectionString, mappingSource)
        {
            OnCreated();
        }

The error:
System.ArgumentException was unhandled
  Message=Invalid value for key 'attachdbfilename'.
  Source=System.Data
  StackTrace:
       at System.Data.SqlClient.SqlConnectionString.VerifyLocalHostAndFixup(String& host, Boolean enforceLocalHost, Boolean fixup)
       at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
       at System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value)
       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Initialize(IDataServices dataServices, Object connection)
       at System.Data.Linq.DataContext.Init(Object connection, MappingSource mapping)
       at Language_Learning_Application.LINQDataContext..ctor() in e:\Germany\Learning Language without dx-Ger -B-1-10-2013\Language Learning Application\Language Learning Application\LINQ.designer.cs:line 50
       at Language_Learning_Application.AddWords.AddWords_Load(Object sender, EventArgs e) in e:\Germany\Learning Language without dx-Ger -B-1-10-2013\Language Learning Application\Language Learning Application\AddWords.cs:line 147
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
       at Language_Learning_Application.Form1.button1_Click(Object sender, EventArgs e) in e:\Germany\Learning Language without dx-Ger -B-1-10-2013\Language Learning Application\Language Learning Application\Form1.cs:line 23
       at System.Windows.Forms.Control.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.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Language_Learning_Application.Program.Main() in e:\Germany\Learning Language without dx-Ger -B-1-10-2013\Language Learning Application\Language Learning Application\Program.cs:line 21
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
 
My connection at Properties is :
Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True
And my database is in my debug folder and it is created by sql server 2012.
Posted 19-Jan-13 1:30am
Edited 19-Jan-13 2:19am
ProgramFOX178.5K
v3
Comments
F.moghaddampoor 19-Jan-13 7:00am
   
I think i have find out the bug. Linq is just working in .net framework 4.0 but when i change .net framework 4.0 to 3.0 in my properties i got an error.
chester_it21 19-Jan-13 8:56am
   
your connections string is problem..........
check and update or recreated connections string.......
F.moghaddampoor 27-Jan-13 9:13am
   
No i installed .net framework 4.5 and my problem was solved. Sql severl local 2012 won't work with .net framework 4.0

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

check your connection string

and connection string properties
  Permalink  
Comments
F.moghaddampoor 27-Jan-13 9:13am
   
No i installed .net framework 4.5 and my problem was solved. Sql severl local 2012 won't work with .net framework 4.0

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100