Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to Create a Candidate Key? 1

Status
Not open for further replies.

Sware

Programmer
Apr 19, 2005
124
US
I have a Visual Basic application that uses the Visual FoxPro Driver to manage .DBF files (tables) created by Clipper. These tables are "free tables" and thus cannot have a Primary Key assigned to them. Can someone provide the code to create a Candidate Key? Thanks.
 
Oops again - I think I'll get it right this time.

[quote}Unfortunately, there is no color highlighting (would be nice).[/quote]

[highlight]If this text is highlighted there is highlighting in TGML.[/highlight]

You can also do color text.
 
It must be too late in the night - one more try.

Unfortunately, there is no color highlighting (would be nice).

[highlight]If this text is highlighted there is highlighting in TGML.[/highlight]

You can also do color text.
 
Sware (and others),

Delighted to hear you'v got it working. I didn't contribute to the later part of this thread because I felt that Ilyad, Olaf and Borislav were giving much more detailed help than I could (especially as I don't know VB). But I was still following it with interest.

It does demonstate how well persistence can pay off. It's satisfying to solve this type of problem.

Re the question of TGML tags, don't forget that you can always click Preview Post to see the effect of the tags before you submit the post.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Swar,

glad you got it working. I said, don't forget the commas...

I think the candidate index does not help AdoDB and it's recordset to figure out the where clause can be simplified to gs_id = some value. In the end it's not a primary key. The candidate key type is very special. But it does help you and in a way is automatic: If you try to insert an gs_id value twice you will get an error.

Okay, regarding TGML, you can also nest TGML tags and so have highlighting within code blocks etc.

If you want to make that code more general (for now it is working with strings only and hardcoded to 86 fields - and beware not to enter "]" in some field!) you should find out how to parametrize the Update statement using an AdoDB.Command Object. Here's an example that calls a stored proc with a parameter:
Bye, Olaf.
 
Okay, one more problem - adding a new record. I discovered the INSERT Command and attempted to use the ARRAY syntax as follows:

Code:
Dim AddStr
AddStr = "INSERT INTO GHM_V70 FROM ARRAY PA"
conn1.Execute AddSql
The PA array has been filled with values for all 87 fields. I get a Syntax Error on the coon1.Execute statement.
 
Simple, because You defined Addstr, not AddSql. But if you use the same name you'll get the next error, because VFP does not work in the same process as your VB app, it has no array pa. So what you would do is build a complete Insert statement a la

Code:
insert into ghm_v70 (field1,f2,..) values ([value1],[v2],...)

But please, before you answer, start a new thread with that question, it's longwinded enough.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top