Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.basic.visual.database > #11
| From | Jason Keats <jkeats@melbpcDeleteThis.org.au> |
|---|---|
| Newsgroups | comp.lang.basic.visual.database |
| Subject | Re: ADODB.Recordset inaccessible |
| References | <j4qgih$emi$1@dont-email.me> |
| Message-ID | <LUYcq.2559$7r4.1754@viwinnwfe02.internal.bigpond.com> (permalink) |
| Date | 2011-09-17 18:30 +1000 |
| Organization | BigPond |
The Dubious Khelair wrote:
> I am working on a project here that has me working with a
> Microsoft SQL database being accessed from an ASP.NET VB page. Up to
> this point I haven't had any problems connecting to the database;
> however, when I attempt to access what is a valid query in the query
> builder, I am not able to see my ADODB.Recordset object's properties or
> methods as far as I can tell. This may well be a very foolish mistake,
> as I'm relatively new at Visual Basic and ASP.NET development as a
> whole.
> Anyway, here is some of the applicable code from which I am
> getting the following error: Exception Details:
> System.Runtime.InteropServices.COMException: Item cannot be found in the
> collection corresponding to the requested name or ordinal.
> It is being raised by the following line of code:
> lblDebugResults.Text = objRecSet(0)
> which is found in the following procedure:
> -=-=-=-=-
> Protected Sub btnQueryDB_Click(ByVal sender As Object, ByVal e As
> EventArgs) Handles btnQueryDB.Click
> Dim strConn, sqlTemp As String
> Dim objConn, objRecSet
> objConn = Server.CreateObject("ADODB.Connection")
> objRecSet = Server.CreateObject("ADODB.Recordset")
>
> 'credentials
> strConn =<THIS IS OMITTED BUT FULLY DEBUGGED>
> objConn.Open(strConn)
>
> sqlTemp = "SELECT (Fname, Lname, Employed) FROM "& _
> Student_Employment" '& _
> ' "WHERE ProgramMajor = "& _
> ddlMajorSelection.SelectedItem.ToString
>
> Try
> objRecSet = objConn.execute(sqlTemp)
> objConn.close()
> Catch ex As Exception
> 'error running query- do something about it here
> lblDebugResults.Text = "Error: "& ex.ToString
> End Try
>
> 'relocate this code once it is debugged properly
> lblDebugResults.Text = objRecSet(0)
>
> End Sub
> -=-=-=-=-
>
> As you can see I've tried to simplify the query for debugging,
> but I'm pretty sure now that the problem is in how I've declared the
> ADODB.Recordset or how I'm trying to access it. After I put in
> objRecSet. the menu which appears only gives me the default items, not
> any ADODB.Recordset specific methods or properties.
> Any help with this matter would be very greatly appreciated, and
> I thank you much in advance for taking a peek at this.
>
>
> -Damon Getsman
>
You can use a disconnected ADODB.Recordset, if you wish, within
(ASP).NET - but you haven't provided a good reason for doing so. It
would be much easier to use ADO.NET to retrieve a DataTable.
However, if you must use ADODB, there's no reason to use late binding.
You should create a reference to Microsoft ActiveX Data Objects 2.8
Library. If you then use correctly typed objects, you get feedback via
intellisense - making it much less likely to make mistakes.
Back to comp.lang.basic.visual.database | Previous | Next — Previous in thread | Find similar
ADODB.Recordset inaccessible The Dubious Khelair <khelair@contract.gateway.2wire.net> - 2011-09-14 15:17 +0000
Re: ADODB.Recordset inaccessible The Dubious Khelair <khelair@contract.gateway.2wire.net> - 2011-09-14 15:26 +0000
Re: ADODB.Recordset inaccessible The Dubious Khelair <khelair@contract.gateway.2wire.net> - 2011-09-15 10:55 +0000
Re: ADODB.Recordset inaccessible The Dubious Khelair <khelair@contract.gateway.2wire.net> - 2011-09-16 12:54 +0000
Re: ADODB.Recordset inaccessible Jason Keats <jkeats@melbpcDeleteThis.org.au> - 2011-09-17 18:30 +1000
csiph-web