"Execute" method not supported in ASP.net

Good morning everyone,

The following snippet of code is a classic ASP search tool that i'm trying to convert to ASP.net. The connection to the DB is a SQLClient.SQLConnection and I previously used ADODB.recordset. The code errors out because it doesnt like the "Execute" method i'm using to run my string. I know this method is not natively supported in ASP.net because it cant find the assembly required to use it. Can anyone tell me another way to execute the string in the following code? Any help would be greatly appreciated.
Thanks in advance,

<%intAdmin = Session("ADMIN")

'added for asp.net
Dim objConn as New Object
Dim objRS as New Object

    'If blnLogin = False Then Response.Redirect(("default.aspx"))
    searchtext = Request.Item("searchtext")
    searchfield = Request.Item("searchfield")
    blnSearch = False
    If Len(Trim(searchtext)) > 0 And Len(Trim(searchfield)) > 0 Then
        strSQL = "SELECT d.id DID, * FROM [tblDocument]  d  LEFT JOIN [tblLocation] l on convert(varchar(50),l.id) = d.docloc "
        Select Case searchfield
            Case "'docident'"
                strSQL = (strSQL) & "WHERE d." & searchfield & " = " & searchtext & " "
            Case "'doctitle'"
                strSQL = (strSQL) & "WHERE d." & searchfield & " = " & searchtext & " "
            Case "'dockeyword'"
                strSQL = (strSQL) & "WHERE d." & searchfield & " = " & searchtext & " "
            Case "'docrel'"
                strSQL = (strSQL) & "WHERE d." & searchfield & " = " & searchtext & " "
            Case "'docloc'"
                strSQL = (strSQL) & "WHERE d." & searchfield & " = " & searchtext & " "
            Case "'docauthor'"
                strSQL = (strSQL) & "WHERE d." & searchfield & " = " & searchtext & " "
            Case Else
                strSQL = (strSQL) & "WHERE d." & searchfield & " like '%" & searchtext & "%' "
        End Select
        strSQL = strSQL & "ORDER BY d.docident, d.doctitle, d.dockeyword, d.docrel, d.docloc, d.docauthor"
        Call mf.ConnectDB()
'errors out here
        objrs = objConn.Execute(strSQL)
        blnSearch = True
    End If
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you can do something like this, using Windows Scripting Host:

Set x = Server.CreateObject("WScript.Shell")
x.Run "c:\yourfolder\yourprogram yourparameters"

You might try it.

Good luck.

This is another sample; right from the ASP.NET documentation: C:\INETPUB\iissamples\sdk\asp\database\AddDelete_JScript.asp(47)

oRs = oConn.Execute ( " Select * from authors where Author= 'Paul Enfield' and YearBorn =1967 " )

I'd imagine it will work as well with strSQL
snappy3273Author Commented:
That example works fine for classic aSP, just not asp.net. I'm searching for the equivalent syntax for .aspx pages. It just doesnt like the oConn."Execute method".
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

You need to use the SqlCommand object not the SqlConnection object to use the execute function.
snappy3273Author Commented:
Hey intreeg,
Could you possibly show me an example on how you use the SqlCommand object?
try this:

SqlConnection Connection = new SqlConnection(ConnectionString);
string SQL = "SELECT something FROM somewhere";
SqlCommand Command = new SqlCommand(SQL, Connection);
SqlDataReader reader;

reader = Command.ExecuteReader();

//do whatever with the reader


This will work, the whole idea of recordsets in .Net has been thrown and and readers are used. All DB connections are slightly different from language to language.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If you wanted that in a table (which uses concepts closer to the old recordset style) you would then just load the reader into a datatable, for example:

//Get reader as shown above then...
DataTable myTable = new DataTable();

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.