Querying the version of MDAC

M

Mark Rae

Hi,

In ASP classic, I used to do something like this:

<%
Sub TestMDAC(pstrConnectionString)

Dim conn
Dim strVersion

Set conn = CreateObject("ADODB.Connection")

conn.ConnectionString = pstrConnectionString
conn.Open
strVersion = conn.Version
conn.Close

End Sub
%>

Is there a native .NET way to do the same? I'm hoping to run this on my
hosted web / database server, so:

1) I can't install and run Component Checker

2) I can't query the Registry

3) I can't query the version of any of the individual files outside my own
webspace

Any assistance gratefully received.

Mark Rae
 
J

Juan T. Llibre

Oops, sorry.

I read right over the requirement that
nothing should be installed at the server.

Reading the Registry might be your only way, then,
although that might be tricky, given that you'd need
access permissions to read the server's registry.

Can you find out the OS and software the server is running ?

The table at : http://support.microsoft.com/kb/231943/
will give you the correct MDAC version for each.

Not too many choices for Server OS's there.
That will narrow down your search quite a bit.

Of course, getting the right version *after* any security patch,
like MS04-003, has been applied might be very tricky, too.
 
M

Mark Rae

I read right over the requirement that
nothing should be installed at the server.

Reading the Registry might be your only way, then,
although that might be tricky, given that you'd need
access permissions to read the server's registry.

See proviso 2) in the OP.
Can you find out the OS and software the server is running ?
Yes.

The table at : http://support.microsoft.com/kb/231943/
will give you the correct MDAC version for each.

Yes indeed, but...
Of course, getting the right version *after* any security patch,
like MS04-003, has been applied might be very tricky, too.

That's the whole point! :)
 
M

Mark Rae

Since the only reason I have for doing this on a live webserver is for
debugging purposes, I'm not concerned about performance etc, so I thought
I'd have a go with InterOp, just for a laugh...

I did the following, obviously specifying the aspcompat page directive as
well:

using System;
using System.Runtime.InteropServices;

public class TestMDAC : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
object objConn = Server.CreateObject("ADODB.Connection"); // this works
string strMDACVersion = objConn.Version;
// this fails
objConn = null;
// this works
}
}

The objConn objects gets created successfully, but I'm unable to interrogate
any of its properties. However, if I add a watch on it, all its properties
are exposed. I can drill down and see its "Version" property which, as
expected, shows 2.8 as the version of MDAC, which is correct.

What do I have to do to interrogate this object's properties? If the Watch
window can do it, I can surely do it in code...

Any assistance gratefully received.

Mark
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top