SQL: Updating records via VB 3.0 (Part II) 
Author Message
 SQL: Updating records via VB 3.0 (Part II)

Ahh, an index.  Theres and idea!  

I made my best attempt to add one, but have gotten no
where. I dont get any errors, but I also dont get an
index.

Heres what I did:

Dim autodb As Database
Dim newidx As New index
Dim newtd As New TableDef
Dim f1 As New field, f2 As New field, f6 As New field
Dim f3 As New field, f4 As New field, f5 As New field
Dim tt As table
c$ = "ODBC; uid=; pwd=; DSN=ALPHA01"
Set autodb = OpenDatabase("ALPHA01", True, False, c$)
On Error Resume Next
autodb.TableDefs.Delete "carinfo"

'Create new table/fields and index
newtd.Name = "carinfo"
f1.Name = "year"
f1.Type = DB_INTEGER
newtd.Fields.Append f1
f2.Name = "make"
f2.Type = DB_TEXT
f2.Size = 15
newtd.Fields.Append f2
f3.Name = "model"
f3.Type = DB_TEXT
f3.Size = 25
newtd.Fields.Append f3
f4.Name = "price"
f4.Type = DB_INTEGER
f4.Size = 10
newtd.Fields.Append f4
f5.Name = "description"
f5.Type = DB_TEXT
f5.Size = 200
newtd.Fields.Append f5
f6.Name = "autokey"   'Added for index
f6.Type = DB_INTEGER
f6.Size = 2
newtd.Fields.Append f6
autodb.TableDefs.Append newtd

' ***** Create index *****
newidx.Name = "Table Index"
newidx.Unique = True
newidx.Primary = True
newidx.Fields = "autokey"
newtd.Indexes.Append newidx
'Also tried: autodb.tabledefs("carinfo").indexs.append newidx
.
.
.
Set tt = autodb.OpenTable("carinfo")
tt.AddNew
tt("autokey") = autokey
tt("year") = LTrim(RTrim(vehicleyear))
tt("make") = LTrim(RTrim(vehiclemake))
tt("model") = LTrim(RTrim(vehiclemodel))
tt("price") = LTrim(RTrim(pricetag))
tt("description") = description
tt.Update
tt.Close
Debug.Print autokey
vehicleyear = ""
vehiclemake = ""
vehiclemodel = ""
pricetag = ""
description = ""

Loop
Close #2
autodb.Close



Mon, 02 Nov 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. SQL: Updating records via VB 3.0

2. Updating a SQL Server Database via VB 3.0

3. Datacombo update part II

4. Update Record to Oracle via ADO or SQL?

5. Getting Task ID in VB Script - Part II

6. Updating Access Records via VB

7. Error doing update with VB 3.0 and SQL Server 6.5

8. Error during update of a dynaset with VB 3.0 and SQL Server 6.0

9. Updating a SQL table with VB 3.0

10. VB 3.0 with SQL SERVER 7.0 (Update, delete and Insert)

11. VB 3.0 with SQL SERVER 7.0 (Update, delete and Insert)

12. VB 3.0 and Dbase II Database

 

 
Powered by phpBB® Forum Software