Re: Connection.Execute causes untrappable runtime error

From: Allcomp (fa097770_at_nospam.skynet.be)
Date: 06/08/04


Date: Tue, 8 Jun 2004 16:31:07 +0200

Hello,

Personally, when I don't want to use the dataenvironment, I open a recordet
so
Set Recordset = Database.Execute ("SQL Syntax")
The count = Recordset.RecordCount

If I want to do a delete or Update, I do a Database.Execute ("SQL Syntax")
I believe that the dataenvironment is the best thing in vb6 (The program are
simpler to understand as there is no SQL in vb6, only some calls to the
dataenvironment object

Marc Allard
Allcomp

"Nicolas" <johnyspeed@bicycle.com> a écrit dans le message de
news:uLvEI70MEHA.3208@TK2MSFTNGP10.phx.gbl...
> Hello All,
>
> This is not a question, but a description of a simple (solved) problem
> and solution which others may be interested in.
>
> I am writing a data processing app in VB6 using ADO. It does everything
> basically using sql statements dynamically built from the user input.
> Some queries are run using the recordset object's open method where
> applicable, and the rest are run using the connection objects execute
> statement.
>
> This results in two possible typical syntax forms:
> (1) rs.open sqlstring, cn
> (2) cn.execute sqlstring
>
> Then I added an extra step into my data processing and my app died on
> the connection execute line. When I say died, I mean a proper runtime
> error - untrappable. XP offered to report the problem to Microsoft -
> and by now they must be sick of me!
>
> I tried everthing I could think of to fix the problem. I copied the
> code to other forms, no luck. I build a complete new app with just the
> offending step, no luck. I reintalled mdac 2.8, no luck. Then I got
> desperate (and since my machine needed a re-prep sometime), I sat down
> to reinstalling my entire pc. I opened my app up an tried it again - no
> luck.
>
> Then logic (which has probably be screaming in your head already...)
> kicked in, and I rebuilt the entire form which hosts the offending code
> from scratch. That how I picked up my VERY SIMPLE error.
>
> I had used the following syntax (the recordset open syntax): cn.execute
> sqlstring, cn
> where cn is a open connection object and sqlstring is a string variable
> containing the sql statement.
>
> The "cn" at the end of the statement is in the place where an optional
> long variable could be used to get the records affected count from the
> execute statement.
>
> The problem, in my eyes anyway, is that it doesn't generate a normal
> trappable runtime error, or a type mismatch, but a "let's report this to
> MS" error - not very friendly or debuggable...
>
> Cheers,
> Nicolas
> http://www20.brinkster.com/intefacesa/
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Re: Dataenvironment newbie - Operation is not allowed when the object is closed.
    ... For example I define a querry in the dataenvironment ... I call this querry TB1. ... there is a recordset DB.rsTB1 (see that there is a rs before ... If you want to launch a SQL "on the fly", ...
    (microsoft.public.vb.database.ado)
  • Re: Problem Accessing JOINed Table Data using Variables
    ... The point being that I did not know explicitly what the recordset field ... "Laurie Eaton" wrote: ... > The SQL is easy and works fine. ... can't find the correct syntax in VB to access the data. ...
    (microsoft.public.access.queries)
  • Repost of Problem with Accessing JOINed Data
    ... I have JOINed two tables in SQL using variables for the table names. ... If the table names were explicit I can use the syntax 'MySet!.value' where ABC is one of the table names. ... So in summary my problem is the VB syntax to access the recordset when the table names used to form the recordset via a SQL JOIN are variables. ...
    (microsoft.public.access.queries)
  • Pass Field Name Using Variable to SQL string
    ... I want to pass field names to an SQL string to identify the current of many ... I want to use a recordset with SQL to identify the current field and edit ... This syntax works perfectly in the SQL to identify the current field in the ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Simple Insert Into...
    ... The form is based on an SQL in the form's Record Source property, ... holds the current text in the control, ... Sometimes the unbound controls do have a value (such as when they are set ... I need this value to assign a unique ID to the entire recordset being ...
    (microsoft.public.access.modulesdaovba)