Solved

SQL PERVASIVE CREATING INDEX GIVES ERROR IN VB6

Posted on 2011-02-19
7
589 Views
Last Modified: 2012-06-27
I use this to create table , works ok
        mystring = "DSN=BIAPRO"          
        dbconn.Open mystring '
        adocat.ActiveConnection = dbconn
        On Error GoTo NoExist                'IF NOT IN TABLE not to delete thus
        klant$ = "MUT01"
        dbconn.Execute ("DROP TABLE " & klant$)

NoExist:
'======
    On Error GoTo Foutje
    strSQL = "CREATE TABLE " & klant$ & "("
    strSQL = strSQL & "MutRecord identity,"
    strSQL = strSQL & "MutYear char(2) NOT NULL,"
    strSQL = strSQL & "MutKlant char(3) NOT NULL,"
    strSQL = strSQL & "MutBoek char(2) NOT NULL,"
    strSQL = strSQL & "MutStuk char(6) NOT NULL,"
    strSQL = strSQL & "MutDate char(6) NOT NULL,"
    strSQL = strSQL & "MutPlace char(1) NOT NULL,"
    strSQL = strSQL & "MutRek char(4) NOT NULL,"
    strSQL = strSQL & "MutBtwFlag char(1) NOT NULL,"
    strSQL = strSQL & "MutBedrag FLOAT NOT NULL,"
    strSQL = strSQL & "MutBtw FLOAT NOT NULL,"
    strSQL = strSQL & "MutReden char(55) NOT NULL,"
    strSQL = strSQL & "wenkilos real NOT NULL,"
    strSQL = strSQL & "MutNewkey char(13) NOT NULL,"
    strSQL = strSQL & "FREEMORE char(151) NOT NULL)"
    dbconn.Execute (strSQL)                 '   ctreate tabel first


but then i need to create index, I do like this in 3 steps

 strSQL = "CREATE UNIQUE INDEX MutRecord ON MUT01 (MutRecord)"
 dbconn.Execute (strSQL)
'''GIVES ERROR  ""

 strSQL = "CREATE INDEX MutNewkey ON  MUT01 (MutNewkey)"
 dbconn.Execute (strSQL)
'''GIVES ERROR  ""

 strSQL = "CREATE INDEX MutBoek  ON  MUT01 (MutBoek)"
 dbconn.Execute (strSQL)
'''GIVES ERROR  ""

0
Comment
Question by:BIAPRO
  • 4
  • 2
7 Comments
 
LVL 18

Expert Comment

by:mirtheil
ID: 34934207
What error?  
You probably don't need to create the key on MutRecord since the field is an Identity and the field should already have an index.  

If you run the queries through PCC, do they work?  
0
 

Author Comment

by:BIAPRO
ID: 34934247
Since I could create the table in my source, after that i entered manualy the index using the pervasive console,
BUT!  i have mut01  upto mut99  and preferre not to do this by hand 99 times

index.jpg
table-names.jpg
0
 
LVL 28

Expert Comment

by:Bill Bach
ID: 34934291
Fyi -- since both field names and index names are stored in the same table (X$File), you cannot have indices with the same names as fields.

I echo Mirtheil's sentiment that you shouldn't need the first one, because of the Field type.
 
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:BIAPRO
ID: 34934339
Ok did retry with only

the get error still:

error.jpg
0
 

Author Comment

by:BIAPRO
ID: 34934345
skipped the 1st index, then got the attached error number
 strSQL = "CREATE INDEX MutNewkey ON  MUT01 (MutNewkey)"
 dbconn.Execute (strSQL)
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 34934529
Did you try changing the index name yet?  Add a prefix like "I_" to the start of the index name to make it unique.
0
 

Author Comment

by:BIAPRO
ID: 34934613
Bingo!   that did  the trick!, and true I see the 1st key index generated without my call for key autoinc
Thanks again Bill,

Regards Jack (aruba)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now