Referencing .NET components on a script page.

G

Guest

In ASP (pre .NET) I referenced components by

MyObj = Server.CreateObject("DllName.Classname")

In .NET, I know that to reference the Sql namespace I use

<%@ Import Namespace="System.Data.SqlClient" %>

What I am trying to do:

I have an ASP web application that uses VB 6 com components and I am trying
to convert it to .NET. The asp page instantiates a COM component that
returns a recordset (ADO) and displays it on the page. I am trying to do it
in .NET with .NET components in my application and display the data with a
SqlDataReader.

Thanks,

Jerry
 
G

Guest

Hi,

For accessing COM component use Type Library Importer create an
assembly as COM is an unmanaged code .Then add an reference in your project.
Below is the syntax
(eg) tlbimp SampleVBComp.dll /out SampleCOM.dll

U can use <%@ Import Namespace="SampleCOM" %> to access from ur page.
but recordset object is not compatible in .NET. To return data from db,use
some other approach in COM component.
 
G

Guest

Santhi,

Thanks for the response, but I am not trying to use COM components. I am
trying to convert the COM components to .NET components and return a dataset
or a datareader from the .NET components and then use the data in the .aspx
page and not in the code behind page.

Thanks,
 
G

Guest

Santhi,

Thanks for the response, but I am not trying to use COM components. I am
trying to convert the COM components to .NET components and return a dataset
or a datareader from the .NET components and then use the data in the .aspx
page and not in the code behind page.

Thanks,
 
G

Guest

Jerry,

Fine..You can create .NET component by using Class Library and move
the logic of getting data from db from COM comp. to .NET Comp and return as
dataset.
Add the .NET Component reference to ur project and u can access the
component in .aspx page using server tags <% %>.Hope this helps you..
 
G

Guest

Santhi,

Thanks.

That does help and I finally got it working. To be more specific (for the
benefit of others) I added a project for the components and in the web
project I added a reference to the component.

In the .aspx page I added the following line:
<%@ Import Namespace="MyClassLibrary"%>

which is preceded only by the following line:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="WebApplication3.WebForm1"%>

The following also helped.

ms-help://MS.MSDNQTR.2003FEB.1033/vbcon/html/vbconwalkthroughcreatingwfccomponent.htm
 

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

Top