CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2011
    Posts
    3

    attach database usig linq to sql

    hello;
    I have a database based on SQL Server 2008 and I want to attach it using a stored procedure LINQ to SQL can someone help me?
    thank you in advance

  2. #2
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: attach database usig linq to sql

    Here's an MSDN walk-through I think will give you a nice step by step way of doing this....

    This was written back in 07... so you may (or may not) have to adjust a little depending on what version of Visual Studio you're using... but shouldn't be too difficult.

    http://blogs.msdn.com/b/zainnab/arch...rocedures.aspx

  3. #3
    Join Date
    Aug 2011
    Posts
    3

    Re: attach database usig linq to sql

    thank's,but you have something for the attachment of the database?

  4. #4
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: attach database usig linq to sql

    Sure, if you are using Visual Studio 2008... click on the "View" menu, then "Server Explorer", right-click on "Data Connections" in the window that appears (see left side of the attached image), then "Add Connection...".

    Fill out the connection dialog and hit the "Test Connection" button to make sure you can hit your database okay... once you've done that, you can explore your database and follow the tutuorial I linked to before... Good luck!
    Attached Images Attached Images  

  5. #5
    Join Date
    Aug 2011
    Posts
    3

    Re: attach database usig linq to sql

    thanks but i know that,
    i want attach my database but not for me ,no , i want that when i make deploiment in load of form the database must attached ,not for me but for the user who work with my application

  6. #6
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: attach database usig linq to sql

    Ah... sorry for the misunderstanding...

    I'm old school... so I honestly don't use Linq too much for data access, I'm still just writing my own data classes using OleDB to handle everything... but... I can tell you that what you will need is to create the appropriate connection string to connect to your database, and you'll have to assign that connection string to your linq object... in the DataContext constructor from what I've read thus far.

    Again, sorry for the confusion... now maybe somebody who uses Linq as your are can chime in with the definitive for you... good luck!

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: attach database usig linq to sql

    I have always just used a bat file and called the SQL Attach function to attach an existing db to the users sql instance.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured