473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using COM objects in ASP .NET

I know this topic is a frequent one, but I haven't found anyone with my specific problem yet (well, at least no one wants to talk about it).

I've tried a couple of methods for getting an old COM object to work within ASP .NET. Here's a simple example:

----
@Import Namespace="eShoppingCart"

Dim objShoppingCart as eShoppingCart.boShoppingCart
Dim sConnectionString, sCartId

sConnectionString = Application("ConnectionString")
sCartId = ""

objShoppingCart = New eShoppingCart.boShoppingCart()

sCartId = objShoppingCart.Generatecart(sConnectionString, Request.ServerVariables("HTTP_USER_AGENT"), Request.ServerVariables("REMOTE_ADDR"), "DEF")
----

I've used the tlbimp.exe to create a wrapper from the old .dll and all that and I've put it in the /bin directory of my web site.

In this example, objShoppingCart is successfully created, but the call to Generatecart fails for an unknown reason.

My question is this: Is there something else obvious or not that I've missed that is necessary to the success of this conversion to .NET? Or is it possible that the object I'm trying to use here just won't work?

(I've also tried the other method using the Server.CreateObject() on the original .dll with the same results)

The function call is successful when run in asp classic with the exact same parameters.

Thanks in advance
Jul 31 '07 #1
2 1379
So, I've figured out that problem was a simple oversight of the Application(...) call. Oops.

However, I'm having difficulty finding out how to use an ADODB.RecordSet in ASP.NET. Do I need to Import some assembly .dll like other COM objects?

Thanks
Jul 31 '07 #2
ilearneditonline
130 Expert 100+
So, I've figured out that problem was a simple oversight of the Application(...) call. Oops.

However, I'm having difficulty finding out how to use an ADODB.RecordSet in ASP.NET. Do I need to Import some assembly .dll like other COM objects?

Thanks
Why would you want to use ADODB.recordset with ASP.NET? You should be using either a datareader or a dataset.

You would do something like this with VB.NET. I don't really use VB.NET but rather C#, but it should be something like below. I always use code behind files, but could be done inline. You should also add some type of error handling to this.

Expand|Select|Wrap|Line Numbers
  1. Public ReadOnly Property ConnectionString() As String
  2.     Get
  3.         Return "Your Connection String"
  4.     End Get
  5. End Property
  6.  
  7. Public Function executeDataReader() As SqlDataReader
  8.     Dim query As String = "SELECT field1, field2, field3 FROM t_table"
  9.     Using conn As New SqlConnection(Me.ConnectionString)
  10.     Dim cmd As New SqlCommand(query, conn)
  11.     cmd.CommandType = CommandType.Text
  12.     cmd.CommandTimeout = 30
  13.  
  14.     'open the connection
  15.     conn.Open()
  16.     return cmd.ExecuteReader(CommandBehavior.CloseConnection)
  17. End Function
Aug 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

40
by: Elijah Bailey | last post by:
I want to sort a set of records using STL's sort() function, but dont see an easy way to do it. I have a char *data; which has size mn bytes where m is size of the record and n is the...
1
by: Matt Alanzo | last post by:
On another newsgroup an Access knowledgable party posted: >You should be able to connect an Access ADP to an existing SQLExpress >database running in SQLS 2000 compatibility mode. The only thing...
19
by: Kamilche | last post by:
I have looked at many object-oriented programming frameworks out there for C. Though the ideas presented are intriguing, and I've used some of them in my own work, they all suffered some drawback...
5
by: Anders Borum | last post by:
Hello! Whilst refactoring an application, I was looking at optimizing a ModelFactory with generics. Unfortunately, the business objects created by the ModelFactory doesn't provide public...
13
by: Andy Baxter | last post by:
Can anyone recommend a good online guide to using objects in javascript? The book I bought (DHTML Utopia) suggests using objects to keep the code clean and stop namespace clashes between different...
1
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select...
10
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL,...
2
by: Veloz | last post by:
Hiya My question is whether or not you should associated related objects in your software using a scheme of id's and lookups, or wether objects should actually hold actual object references to...
18
by: Angus | last post by:
Hello We have a lot of C++ code. And we need to now create a library which can be used from C and C++. Given that we have a lot of C++ code using classes how can we 'hide' the fact that it is...
1
by: bizt | last post by:
Hi, Im currently looking to move into using JSON for AJAX instead of returning from the server a string like the following: 12345{This is a text string{true I prefer objects because I dont...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.