29/08/09 21:04
fusebyte
Sub CreateNewMDB(FileName, Format) Dim Catalog Set Catalog = CreateObject("ADOX.Catalog") Catalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Jet OLEDB:Engine Type=" & Format & _ ";Data Source=" & FileName End Sub 'Crea nuovo database 'CreateNewMDB "C:\test.mdb", Jet4x 'Apre il database creato e aggiunge una tabella con alcune colonne. Set tbl = CreateObject("ADOX.Table") Set cat = CreateObject("ADOX.Catalog") ' open the Catalog. cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _ "Data Source='test.mdb';" Membri di ADODB.DataTypeEnum Const adInteger = 3 Const adVarWChar = 202 Const adBinary = 128 Const adDate = 7 Const adDecimal = 14 Const adDouble = 5 Const adLongVarWChar = 203 tbl.Name = "prenotazioni" tbl.Columns.Append "Codice", adInteger tbl.Columns.Append "Nome", adVarWChar, 50 tbl.Columns.Append "Cognome", adVarWChar, 50 cat.Tables.Append tbl Set tbl = Nothing Set cat = Nothing Set Rs = CreateObject("ADODB.Recordset") Set oConnection = CreateObject("ADODB.Connection") oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='test.mdb';" Rs.ActiveConnection = oConnection Rs.CursorType = 1: Rs.LockType = 3 ' Imposto il nome della tabella in cui scrivere Rs.Source = "prenotazioni" Rs.Open 'Aggiungo un record nuovo e ci scrivo Rs.AddNew Rs("Codice") = 7 Rs("Nome") = "Mario" Rs("Cognome") = "Rossi" Chiedo ad ADO di scrivere il record creato. Rs.Update
puoi lavorare su questo gia' funzionante e cambiare i nomi
Ciao
Ultima modifica effettuata da fusebyte 29/08/09 21:05
aaa