I want to use my strongly typed dataset classes created by Visual Studio 2005 in a classic ASP program. I'm having some trouble.
I created the dataset by adding a DataSet object (.xsd) to the project, then I dropped a table schema and took all of the defaults. This created the Fill and GetData methods. I tested it using a command-line program and everything works fine. Here's the test code:
DocsTableAdapter adapter = new DocsTableAdapter();
DocumentDataset.DocsDataTable docs = adapter.GetData();
foreach (DocumentDataset.DocsRow doc in docs)
Console.WriteLine (doc.Name + "\t" + doc.Title + "\r\n");
Everything looked good. So I checked the "Make assembly COM-Visible" and "Register for COM Interop" boxes and added a signature with a strong name key file. Just to be safe, I also ran regasm and gacutil:
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -i $(TargetPath)
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe $(TargetPath) /verbose
Now to my ASP file. Here's what it looks like:
dim Adapter
set Adapter = Server.CreateObject _
("Documents.DocumentDatasetTableAdapters.DocsTableAdapter")
dim Docs
set Docs = Server.CreateObject _
("Documents.DocumentDataset.DocsDataTable")
Docs = Adapter.GetData()
set Docs=nothing
set Adapter=nothing
The first CreateObject works fine, but the second reports "Invalid class string". So I looked in regedit and noticed that something changed the second period into a plus sign. So I changed it to:
set Docs = Server.CreateObject _
("Documents.DocumentDataset+DocsDataTable")
And now the error is simply
Server object, ASP 0177 (0x80131509)
with no human text to help.
I can't find any help, so I hope someone here can help. Just to make sure the object was being found, I tried this:
dim Adapter
set Adapter = Server.CreateObject _
("Documents.DocumentDatasetTableAdapters.DocsTableAdapter")
dim Docs
Docs = Adapter.GetData()
That gave the same error, so I invoked the method without assigning it:
dim Adapter
set Adapter = Server.CreateObject _
("Documents.DocumentDatasetTableAdapters.DocsTableAdapter")
Adapter.GetData()
Sure enough, I can see from the Sql profiler that hit the database and it returned the necessary data with no errors. But I can't use the data! I thought it might be a permissions problem, so I started promoting the IUSR_ and IWAM_ user permissions, eventually making them Administrators (danger) to no avail. I also made those users database administrators. Still didn't help.
Any help
Brian.

COM Interop problem using generated Datasets
Cylon2005
I discovered something else, but I still can't figure out the problem.
It has something to do with System.Data.DataTable. When I create a new class at the same level as the class that inherits DataTable, it intantiates. Of course, there's no functionality, but at least it doesn't throw that unknown error:
public partial class DocsDataEmptyTable : System.Collections.IEnumerable
{
ArrayList Rows = new ArrayList();
public virtual System.Collections.IEnumerator GetEnumerator()
{
return Rows.GetEnumerator();
}
}
I can't find anything in the .NET documentation that would suggest that I can't instantiate a DataTable inside of a COM wrapper.
Any help would be greatly appreciated!