views:

143

answers:

2

I have a program that contains .dbml files. I created this file with Server Explorer.

I want to execute this program on other computers but I seem to be having issues with dependencies because I use LINQ.

How can I fix this?

A: 

Can you be more specific? What errors are you encountering? Did you use SQL Passwords or Network authentication? Do your users have network accounts added to SQL? Is this a permission based error?

Just one other possibility: Your users should have .NET 3.51 installed on their systems or they won't get the best possible Linq support. They might not have the Linq assemblies at all.

David Leon
A: 

Yeah, we need more info, but I'm guessing you're having problems with the ConnectionString? as in, there's a connection string in your DBML designer file, and it doesn't match your production DB connection string?

If this is the case, then perhaps write a class that handles all instantiations of your DataContext in your code.

Then, within that class, whenever a new datacontext is created, you override the DBML connectionstring with your current connectionstring, probably from your web.config. this ensures your LINQ stuff is always connected to the correct DB during runtime.

Perhaps something like this (the property names might differ):

Public Shared Function GetNewContext() As YourDataContext
   Dim dContext As YourDataContext

   dContext = New YourDataContext()
   dContext.Connection.ConnectionString = MyConnectionStringFromTheWebConfig()

   Return dContext

End Function

andy