moosetracker (5) [Avatar] Offline
#1
I got this working on my main computer, but my laptop gets this error. It seems so generic I am unsure what is wrong.

I get all the way down to the foreach (var contact in contacts)
console.writeline... (which to my limited knowledge seems to say the DB opened and I successfully Queryed..

But then when I try to read & write.. I get this error.

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.

my mainframe has professional. my laptop only C# express. I made sure that the northwnd.mdf was in the same directory path for both..

So why can it work on one machine but not the other?

I prefer the laptop for mobility while studying, although I don't have the same disk space, it is more mobil.
fabrice.marguerie (224) [Avatar] Offline
#2
Re: Error running Hello LINQ to SQL
SQL Server has whole set of really useless error messages, which makes it very difficult to determine what's the root of the problem.

Anyway, what you can try is attaching the database (the .mdf) file to SQL Server. This can be done using a command line interface or a GUI such as SQL Server Management Studio (Express or not). Then, instead of simply using a file path as the parameter of the DataContext constructor, you can use a real connection string. It this connection string, you'd indicate the name of your server instance (.SQLEXPRESS in your case I guess) and the name of the database (the name you choose yourself when attaching.

To know how a connection string looks like, you can visit http://www.connectionstrings.com

PS: we used a file path instead of a connection strings precisely because it was supposed to be easier, but as usual, it doesn't seem to always be the case.
moosetracker (5) [Avatar] Offline
#3
Re: Error running Hello LINQ to SQL
Thanks,

For work I will end up needing that type of link anyway as we have a True SQL DB.. Plus I hope, I can use Link for Informix and other DB's ... The part of the link in the web site, I have done before. The thing I will need is what commands of Linq are used to place either the OLE or ODBC to.. Do I just shove this into the DataContext(...) or does this just take a path name and I need to use something else. I skipped ahead to the LInq to SQL, and although I see the Datacontext(liaConnectionString).. I don't see anything stating what liaConnectionString is.. Does the book touch onto connecting to other sources?
jwooley (123) [Avatar] Offline
#4
Re: Error running Hello LINQ to SQL
We do discuss other databases in the book. LINQ to SQL does not support other platforms other than the SQL Server family of products (Sql Server, Express, and runtime support for Compact). If you need support for other database platforms, you will likely need to turn to the Entity Framework, or one of the other LINQ enabled OR/M tools such as LLBLGen, NHibernate, Genesis, etc.)

Jim
moosetracker (5) [Avatar] Offline
#5
Re: Error running Hello LINQ to SQL
That's so sad.. Our company keeps buying software without thinking of the data platform. Now they want US to pull it all together.. We can get to it poorly with a bridge that is poorly designed and using ODBC.. I was so hoping LINQ with it's discription of "LINQ provides a high-level abstraction of virtually any data and emulates the query operations of the relational model." would be the answer.

Right now the bridge will let us pull the records out, then we have to slowly put record by record into a SQL DB in order to query it. It wont let you combine tables, or query on tables. This is a long tedious and totally redundancy of the data just to work with it.