Solved

VB6 code to create a db and Table

Posted on 2002-04-16
8
183 Views
Last Modified: 2010-05-02
I need help with this vb6 code. It worked at one time and created a database m086.mdb
However, now it gives me an ISAM error before the create. I can't figure out why.

Also, when it DID create the m086.mdb it would not continue and create a table in the new db. How do I then get the table into the m086.mdb?

Private Sub CreateClass_Click()
'CreateDatabase()
On Error GoTo ErrorCreateDB
Dim Cat As New ADOX.Catalog
Dim Tbl(5) As ADOX.Table
Dim Idx() As ADOX.Index
Dim msgErrR As Integer
Dim sCnn As String
NuevaDB$ = "m086"

sCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:reEngine Type=5;" + "Data Source=" + NuevaDB$ + ".mdb"

'error next statement:"can not find installable
'ISAM.
' At one time I did NOT get this error now I do !

Cat.Create sCnn
'what code do I need HERE to create a table with specs below?

Stop
Set Tbl(5) = New ADOX.Table
Stop
Set Tbl(5).ParentCatalog = Cat
Stop
With Tbl(5)

.Name = "ClassList"

.Columns.Append "Password", adVarWChar, 5

.Columns.Append "StudenNumber", adInteger

.Columns("StudenNumber").Properties("AutoIncrement").Value = True

.Columns("StudenNumber").Properties("Nullable").Value = False

.Columns.Append "StudentFirst", adVarWChar, 25

.Columns("StudentFirst").Properties("Nullable").Value = False

.Columns.Append "StudentLast", adVarWChar, 25

.Columns("StudentLast").Properties("Nullable").Value = False

.Columns.Append "TeacherFirst", adVarWChar, 25

.Columns("TeacherFirst").Properties("Nullable").Value = False

.Columns.Append "TeacherLast", adVarWChar, 25

.Columns("TeacherLast").Properties("Nullable").Value = False
End With

Stop
ReDim Idx(1)
Set Idx(0) = New ADOX.Index

Idx(0).Name = "ClassID"

Idx(0).IndexNulls = adIndexNullsAllow

Idx(0).Unique = True

Idx(0).Columns.Append "Password"
Set Idx(1) = New ADOX.Index

Idx(1).Name = "PrimaryKey"

Idx(1).PrimaryKey = True

Idx(1).Unique = True

Idx(1).Columns.Append "StudenNumber"
For i = 0 To UBound(Idx)

Tbl(5).Indexes.Append Idx(i)
Next i
Stop
Cat.Tables.Append Tbl(5)
Stop
Set Cat = Nothing
Exit Sub

ErrorCreateDB:

msgErrR = MsgBox(" Error No. " & Err & " " & vbCrLf & Error, vbCritical + vbAbortRetryIgnore, "Code Gen Error")

Select Case msgErrR

Case Is = vbAbort

If Not (Cat Is Nothing) Then

Set Cat = Nothing

End If

Exit Sub

Case Is = vbRetry

Resume Next

Case Is = vbIgnore

Resume

End Select
End Sub


0
Comment
Question by:mathprof
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 1

Expert Comment

by:Neo78
ID: 6946514
Hey mathprof

this is a duplicate of the question u posted at:

http://www.experts-exchange.com/visualbasic/Q.20290258.html

delete this Q and get back your points. thanks


EE Mods:
Pls delete this Q as it is a duplicate post and refund the points back to mathprof.

Regards.
0
 
LVL 3

Expert Comment

by:sridhar_PJ
ID: 6946741
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6946747
Why dont you use pure SQL statement to create the table and append fields?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 1

Expert Comment

by:Moondancer
ID: 6977210
This question is reasonably current, others below are not.  All of them need your attention.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if they are still open in 14 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20102401.html
http://www.experts-exchange.com/questions/Q.20116302.html
http://www.experts-exchange.com/questions/Q.20130066.html
http://www.experts-exchange.com/questions/Q.20280137.html
http://www.experts-exchange.com/questions/Q.20290269.html

To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20108488.html

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @14 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 

Author Comment

by:mathprof
ID: 6978338
It is in error a duplicate of another question.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6989170
Hi mathprof, there are comments here already.
Cheers
0
 

Author Comment

by:mathprof
ID: 6991797
It is a duplicate
0
 
LVL 1

Accepted Solution

by:
Moondancer earned 0 total points
ID: 7055082
100 points refunded, but question will not be deleted, has value.  Moved to PAQ at zero points instead.  You cannot delete a question once comments have been added, without Moderator assistance.

Moondancer - EE Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

860 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