Reference an outside database

Topics: Troubleshooting
Jul 26, 2011 at 8:11 PM

I have been searching and I still can not find out how I can populate a simple table with data from a database. I have tried modules but got the error : and the workaround doesn't work because it thinks it is missing an assembly reference =(.

Jul 26, 2011 at 8:20 PM

So why don't you add the assembly reference?

Jul 26, 2011 at 8:35 PM

Did and it is still said it could not find the assembly reference. I also am righting this as a C# script and the having razor call it.

Jul 26, 2011 at 8:38 PM

Can you be a little more specific? What is the error message? How did you add the reference?

Jul 26, 2011 at 8:54 PM

CS0246: The type or namespace name 'TransactionScope' could not be found (are you missing a using directive or an assembly reference?) is the error and here is the code I am using

using (new TransactionScope(TransactionScopeOption.Suppress)) { cnn.Open(); }

and if I add:

using System.Transactions

The error is:

CS0234: The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?)

These are all of the references I have:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
Jul 26, 2011 at 9:02 PM

Using is not adding assembly reference, it's telling the compiler that you are going to use that namespace. To actually add the assembly, right-click the project in VS and add reference, or if you are not using VS, edit the csproj file to add it.

Jul 26, 2011 at 9:16 PM
Edited Jul 26, 2011 at 9:26 PM

Another error:

Error compiling module "Database" from file "/Modules/Database/Database.csproj":
The assembly reference 'System.Transaction' could not be loaded.

All I added was

<Reference Include="System.Transaction" />

to the .csproj

I am using WebMatrix. Will be back in tommorow hope to find out whats wrong. =) Thanks


Jul 26, 2011 at 9:27 PM

System.Transactions, with an s.

Aug 12, 2011 at 4:56 PM

Thanks I finally got to test it today and it worked thanks for your help.