change an index in the db

  • Thread starter Thread starter Guy Cohen
  • Start date Start date
G

Guy Cohen

Hi all,

I use VB6 and Access MDB file.
One of the columns is indexed with no doubles.
How do I write a patch to the user so the index is changed to allow doubles?

TIA
Guy
 
Public Sub ChangeIndex()

Dim objConnection As ADODB.Connection
Dim strDropSQL As String
Dim strCreateSQL As String

'Change this to include your actual index
'name, table name and field name.
strDropSQL = "DROP INDEX TestText ON tblTest"
strCreateSQL = "CREATE INDEX TestText ON tblTest(TestText)"
Set objConnection = New ADODB.Connection
With objConnection
'Change this to point to the actual path and name of your MDB.
.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = C:\Documents and Settings\Brendan Reynolds\" & _
"My Documents\Blog\Test2.mdb"
.Open
.Execute strDropSQL
.Execute strCreateSQL
.Close
End With

End Sub
 
Found it.......

CON.Execute ("DROP INDEX F1 ON Table1;")
CON.Execute ("CREATE INDEX F1 ON Table1 (F1);")

Guy :)
 
Back
Top