Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Bernard Bout
  Where is Bernard Bout?
 Brisbane
 Australia
 Bernard Bout
 To: Benny Thomas
  Where is Benny Thomas?
 Jeddah
 Saudi Arabia
 Benny Thomas
 Tags
Subject: RE: Bernard CA New Tutorial Part 3
Thread ID: 208997 Message ID: 209584 # Views: 6 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Monday, December 29, 2008 6:02:04 PM         
   


> Dear Mr. Bernard,
>
> Sorry for the hassle.

That's ok. I am patient up to a point.

> > 1. You don't say which tutorial you are talking about. If it is CREATING & USING CA CLASSES – A SIMPLE TUTORIAL PART II then what can I say? You obviously did not follow it correctly. I just did and it worked exactly as in the tutorial.
>
> Since the topic itself is about the 2nd Tutorial (although Samir mentioned Tutorial Part 3) - I did not specifically mention that I am talking about Tutorial Part II. (As for the first tutorial, I do not see any problem now after I followed your last instructions about the same - I am able to make look up cursors from either Native tables or SQL database or MySQL database).

That is actually the second post on the same (1st) tutorial as is the 3rd post.

>>(although Samir mentioned Tutorial Part 3)

That is part 3 of Tutorial 1. If you read the thread you will know that.


>
> > 2. You don't say whether you are using SQL Server or VFP Native tables
>
> I mentioned that with VFP Native tables everything went on well and no problem here. I had problem with SQL database only. I also mentioned that the Test Connection returned ok - there is nothing like connection in case of native tables, I suppose.

If you still want to work with VFP tables then use separate caBaseClass. Don't mix and match native and SQLServer in the same classlib for this tutorial. Once you know how then experiment.

>
> > 3. You use the EVALUATE function wrongly and then say you have an error. Please look up EVALUATE usage in the help file. What do you get when you type:
>
> I was refering to the following line in one of your earlier posts.
>
>
> ThisForm.DataEnvironment.DataSource = = EVALUATE(oConn1)

A Typo

> 

>
> VPF help does not say that you have to enclose the variable name in quotes. Following is an example given in help file.
>
>
> cMathFunc="INT(4.33)"
> nResult=EVALUATE(cMathFunc)
> ?nResult
> 


In the sample above cMathFunc is already a string! So you are EVALUATing a string not an integer.
If you type

?cMathFunc you get INT(4.33) the string as VARTYPE(cMathFunc) will show.

>
> However,
>
>
?EVALUATE("oConn") 

>
> returns a positive number. Confusing as to the usage of quotes : when to use and when not to use.

There is no confusion. You EVALUATE() a string.

>
> > How would I know from way over here? How do I know what step you missed or added or changed? Send me a sample please.
>
> I am attaching the class and forms. Sub-class caOrders is for native tables (formnatup) and caOrdersSQL is for sql database (formsqlup). Pls check the code in Load of form Formsqlup - is it necessary? I inserted this code after I got the error mentioned in my earlier post (crsOrders not found).

You have not followed the tut properly. See below.

Even after this lines of code, error is the same. My connection string for sql is Driver={SQL Server};server=benny\sqlexpress;database=Northwind. Please change this accordigly. You are reqeusted to kindly go through the classes/forms at your convenience and help me to correct my mistakes.

There is no need for those lines in the LOAD().

>
> Regards,
>
> Benny
>
>
> https://www.foxite.com/uploads/d3c95fce-2857-4837-9528-99b0dc10c7e1.rar

Hi Benny

I have looked at your sample code you uploaded. The problem is that you cannot seem to follow simple step by step instructions and have skipped over some crucial ones. In the tutorial (please read it again) in Step 1 the second instruction is this:

When the class opens in the class designer, Rt. Click it and select “Builder”. Enter a dummy name for the alias. We will change this later. Make sure the check box “Use DataEnvironment…” is ticked.

You have NOT followed that step at all!!!! Check your caBaseClass and see if there is any code in the INIT. There is none. There will be, if you follow that step above.

From now on we will be using only SQLServer and not Native tables.

Also we will be following the tutorial every step and not skipping any steps. I cannot help you if you do not follow the tutorial exactly. Once you know how to use CA's then you can experiment.

Secondly you have also skipped over this step:
So in the INIT of the class add this code as in the black box:


Why may I ask are you skipping over these steps?

I suggest you delete those classes and start all over again from STEP1 but this time follow the tut exactly.

A suggestion
In most apps you will be using a variable e.g. oConn throughout your app. In this variable you will store your connection handle. So get used to using that variable:

Once you have VFP open, type in the command window:

oConn = SQLSTRINGCONNECT([Driver={SQL Server};server=benny\sqlexpress;database=northwind;Trusted_Connection=yes;])


?oConn will then print a positive number if you have connected.

That will make your oConn scope visible in VFP. And when selecting a connection in the builder select the first item "Use existing Connection String" and enter oConn there. That way you get used to doing it the proper way for use in an app.

Let me know how you go and post your code here if you get any more errors.

Bernard

** If you see someone without a smile, give em one of yours :) **
My Blog 8-)

ENTIRE THREAD

Bernard CA New Tutorial Part 3 Posted by Samir Ibrahim @ 12/23/2008 1:18:40 PM
RE: Bernard CA New Tutorial Part 3 Posted by mike castillo @ 12/23/2008 2:14:59 PM
RE: Bernard CA New Tutorial Part 3 Posted by Samir Ibrahim @ 12/23/2008 3:47:39 PM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/24/2008 2:23:22 AM
RE: Bernard CA New Tutorial Part 3 Posted by Benny Thomas @ 12/24/2008 7:44:25 PM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/25/2008 1:09:05 PM
RE: Bernard CA New Tutorial Part 3 Posted by Benny Thomas @ 12/25/2008 6:57:17 PM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/27/2008 6:57:21 AM
RE: Bernard CA New Tutorial Part 3 Posted by vivek deodhar @ 12/27/2008 5:58:12 AM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/27/2008 7:04:00 AM
RE: Bernard CA New Tutorial Part 3 Posted by Mike Yearwood @ 12/27/2008 4:06:01 PM
RE: Bernard CA New Tutorial Part 3 Posted by vivek deodhar @ 12/29/2008 5:42:39 AM
RE: Bernard CA New Tutorial Part 3 Posted by Mike Yearwood @ 12/27/2008 4:07:55 PM
RE: Bernard CA New Tutorial Part 3 Posted by Benny Thomas @ 12/28/2008 2:04:35 PM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/29/2008 3:41:41 AM
RE: Bernard CA New Tutorial Part 3 Posted by Benny Thomas @ 12/29/2008 9:35:38 AM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/29/2008 6:02:04 PM
RE: Bernard CA New Tutorial Part 3 Posted by Mike Yearwood @ 12/29/2008 8:45:10 PM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/30/2008 2:50:22 AM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/30/2008 2:56:26 AM
RE: Bernard CA New Tutorial Part 3 Posted by Mike Yearwood @ 12/30/2008 4:01:38 AM
RE: Bernard CA New Tutorial Part 3 Posted by Bernard Bout @ 12/31/2008 5:39:06 AM
RE: Bernard CA New Tutorial Part 3 Posted by Mike Yearwood @ 12/31/2008 4:11:38 PM