Can u help in tellin me the process of adding a Ms Access database to vb 6.

Recommended Answers

All 3 Replies

If you are saying "adding to vb6" are you talking about creating a table etc?

it is very easy process, first open ur vb, go to project menu, then components option and select Microsoft ADO Data Control 6.0, and then draw it on ur form, then create a connection, by right clicking on ADODC..and then click on Build button and select Microsoft jet 4.0 OLE DB Provider, and press next button and select a database that u have created in MS Access,and then press ok, and then go to record source and select no. 2 from combo 2-adCMDtable and the tables will b shown blow, select table from there, and then take ur controls in which u want to call data fielsds..go to those control's properties and set Data Source Adodc, and data filed.

commented: Nicely listed +6

Try the following if you are trying to create a table by VB 6 code.

Private Function CreateTable() As Boolean
  Dim catDatabase As ADOX.Catalog
  Dim oTable As ADOX.Table
  Dim bCreateTable As Boolean
' -------------------------------
  On Error GoTo PROC_ERR
  
  
  bCreateTable = False
  
  Set catDatabase = New ADOX.Catalog
  With catDatabase
	.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
						"Data Source='C:\TestDB.mdb';"
	
	Set oTable = .Tables("Priorities")
  End With
  
PROC_EXIT:
  
  If (bCreateTable) Then
	Set oTable = New ADOX.Table
	With oTable
	  .Name = "Priorities"
	  Call .Columns.Append("Priority_ID", adInteger)
	  Call .Columns.Append("Description", adVarWChar, 20)
	End With
	
	Call catDatabase.Tables.Append(oTable)
  End If
  
  If (Not catDatabase Is Nothing) Then
	Set catDatabase = Nothing
  End If
 
  CreateTable = bCreateTable
PROC_ERR:
  Select Case Err.Number
  
	bCreateTable = True
	Err.Clear
	Resume PROC_EXIT
  Case Is <> 0
	MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdCreateTable_Click of Form frmMain"
	bCreateTable = False
	Err.Clear
	Resume PROC_EXIT
  End Select
End Function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.