Northwind DB compile error

S

Space Cowboy

I cant get accessdb.cs to compile. I show my
directory,program,compile. The directory came from a book zip. I
created the Northwind.dll from Northwind.cs which contains the
namespace nwind. The crux of the problem is Northwind.cs which I
assume was created from SQLMETAL which is a mapping of Northwind.mdf.
It shows Northwind takes 2 parameters. Every Internet example shows
just the connect string.

I know Im probably barking up the wrong tree. When I get past the
compile error then I assume I need to have
some SQL service running. Im hoping LINQ didnt need a SQL service
with Data Source(local).

Ill settle for a clean compile and then worry about the runtime.

Thanks,
Jim

03/29/2011 10:42 AM <DIR> .
03/29/2011 10:43 AM 230 accessdb.cs
03/29/2011 04:55 AM 143,697 Northwind.cs
03/29/2011 04:55 AM 39,935 Northwind.dbml
03/29/2011 05:37 AM 86,016 Northwind.dll
03/29/2011 04:55 AM 4,194,304 Northwind.mdf
03/29/2011 04:55 AM 41,416 Northwindmap.xml
03/29/2011 04:55 AM 1,048,576 Northwind_log.LDF

findstr /i Northwind Northwind.cs

public Northwind(string connection,
System.Data.Linq.Mapping.MappingSource mappingSource) :
public Northwind(System.Data.IDbConnection connection,
System.Data.Linq.Mapping.MappingSource mappingSource) :

type accessdb.cs

using System;
using System.Data.Linq.Mapping;
namespace nwind
{
class database
{
static void Main()
{
nwind.Northwind db = new nwind.Northwind(@"Data
Source=(local);Initial Catalog=Northwind");
}
}
}

csc /r:Northwind.dll accessdb.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
accessdb.cs(9,28): error CS1729: 'nwind.Northwind' does not contain a
constructor that takes '1' arguments
Northwind.dll: (Location of symbol related to previous error)
 
S

Space Cowboy

You talking to me. One foot forward. The following compiles with
warnings and executes with a runtime error it couldnt find a SQL
server. The Table entry I picked up from MSDN and generates conflict
warnings with the Table Customer in nwind otherwise it wouldnt compile
GetTable<Customer>. The mappingsource I picked up from SQL website.
I get exactly the same runtime error if I use the ADO DataContext.

Its too bad all the Northwind DB LINQ examples assume alot of other
stuff that doesnt get mentioned.

using System;
using System.Linq;
using System.Data.Linq.Mapping;
using System.Data.Linq;
namespace nwind
{

[Table(Name = "Customer")]
public class Customer
{
[Column(IsPrimaryKey = true)]
public string CustomerID;
[Column]
public string City;
}

class database
{
public static System.Data.Linq.Mapping.MappingSource mappingSource
= new AttributeMappingSource();
static void Main()
{
nwind.Northwind db = new nwind.Northwind(@"Data
Source=(local);Initial Catalog=Northwind",mappingSource);
// DataContext db = new DataContext("Northwind.mdf");
Table<nwind.Customer> Customers =
db.GetTable<nwind.Customer>();
var q = from c in Customers where c.City == "London" select c;
foreach (var cust in q)
{
Console.WriteLine("id = {0}, City = {1}", cust.CustomerID,
cust.City);
}
}
}
}
 
S

Space Cowboy

I was referring to replying to my own post. Your link is just another
example of some magic behind the scene that the Visual Studio takes
care of for you. Who knows maybe it is making Registry entries for
the DB. At the minimum I would expect to see a connection string. My
LINQ example couldnt get more trivial, retrieving records from a DB.
When I resolve the connection problem Ill post back. The Table class
is an example ORM table entity mentioned in MSDN describing
NorthWind. It clashes with what is apparently generated by SQLMETAL
in the Northwind.cs DB mapping.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Repeated WMI DCOM errors 0
repeated DCOM errors 0

Top