PDA

View Full Version : Acess VBA code conversion to C# using LINQ to SQL


rawger
11-13-2008, 05:50 PM
Hey guys,

I have a project which requires me to change some Access VBA code into C# code using LINQ to SQL. Does anyone have any suggestions on how to proceed on this?? Does Microsoft Visual Studio 2008 or 2005 have any functions like that ??

Your comments are much appreciated :tiphat:

Andy
11-14-2008, 01:39 PM
Make sure you have .NET 3.5 for the latest libraries that supports LINQ. Using LINQ-SQL in C# is a blast. I use VS2008 so I don't know how VS2005 is wrt LINQ
Here is some example code
using System;
using System.Linq;
using System.Data.Linq;
using nwind;
Northwind db = new Northwind(@"Data Source=.\SQLEXPRESS;Initial Catalog=Northwind");

var custs =
from c in db.Customers
where c.City == "Rio de Janeiro"
select c;
foreach (var cust in custs)
Console.WriteLine("{0}", cust.CompanyName);

The tasks that you have to do now is to get a connection string that will connect to your SQL server from the Access/VBA string.