Re: Build new Access database from .NET application.
From: Rich Wallace (rich.wallace_at_minusthecannedmeat.jfsheadotcom)
Date: 07/28/04
- Next message: Silvia Brunet Jones: "Re: URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C#"
- Previous message: Cowboy \(Gregory A. Beamer\) [MVP]: "Re: URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C#"
- In reply to: Cor Ligthert: "Re: Build new Access database from .NET application."
- Next in thread: Cor Ligthert: "Re: Build new Access database from .NET application."
- Reply: Cor Ligthert: "Re: Build new Access database from .NET application."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 28 Jul 2004 12:52:15 -0700
Thank you for the answers...
I was able to create the mdb file and, by using and XSD, I can create the
main table and structure. All I need now is the actual export process from
the data source (SQL) to the MDB file.
Here's what I have thus far...
--------
Private Sub ExportData(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExport.Click
Dim oSave As New clsDataExport
oSave.CreateNewDatabase("<serverpath>\<Share>")
End Sub
--------
Public Sub CreateNewDatabase(ByVal DbFile As String)
Dim catNewDB As New ADOX.Catalog()
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source="
& DbFile)
catNewDB.ActiveConnection.Close()
ImportDBStruct(DbFile)
End Sub
--------
Private Sub ImportDBStruct(ByVal sPath As String)
Dim oAccApp As New Access.Application()
Try
oAccApp.OpenCurrentDatabase(sPath)
oAccApp.ImportXML(ConfigurationSettings.AppSettings(eliantexport.Web.Global.
CfgStructXSD) AcImportXMLOption.acStructureOnly)
oAccApp.CloseCurrentDatabase()
Catch ex As Exception
EventLog.WriteEntry("Data Export", ex.Message)
End Try
End Sub
--------
I like using the ImportXML method since I have full control of the main
structure and I can alter the XSD if structure changes in any way rather
than having to manage mode code.
My next step is to extract certain records from a SQL Server database based
on one or more records selected by the user. Here's an idea of what my grid
looks like to the user:
ID Product OrderDate SubmitOrder
1 Binder 7/15/2004 Yes (checkbox)
2 Pens 7/15/2004 No (checkbox)
This may sound a bit confusing so bear with me...
The records in the datagrid is a very small subset of the actual data I need
to send out to the Access database. So I run the inital query to bring back
only the data above and allow the user to select which records they want to
submit. Once they have all of the records selected that they want submitted
and click on the 'Submit' button, I need to know what records in the
datagrid have a SubmitOrder value of 'Yes', and then take only those records
and extract the ID value and then retrieve and populate a new dataset with
the details of the data and then send those records to the Access database,
in this case, only the record for the 'Binder' product, or ID = 1.
I was thinking maybe a loop routine, but if it's cleaner and easier, maybe
somehow push the dataset to the Access file?
"Cor Ligthert" <notfirstname@planet.nl> wrote in message
news:%23hWiXCIdEHA.3016@tk2msftngp13.phx.gbl...
> Hi Rich,
>
> I never tried it, however in my idea this should be posible.
> You can make an access file using ADO ext 2.7 and create the tables.
>
> In the dataset columns is the information about those columns, however as
> far as I know not one by one usable in the create so that should be
convert
> that first using select case or an if statement.
>
> Than it should be in my opinion be easy to do what you want using the
create
> table and the command.executenonquery.
>
> And after that a normal update of the dataset.
>
> (However I think it is easier to write direct the create statements with
the
> proper columnnames and types, when you want that therefore I have a sample
> in VBNet)
>
> I hope this helps a little bit?
>
> Cor
>
>
- Next message: Silvia Brunet Jones: "Re: URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C#"
- Previous message: Cowboy \(Gregory A. Beamer\) [MVP]: "Re: URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C#"
- In reply to: Cor Ligthert: "Re: Build new Access database from .NET application."
- Next in thread: Cor Ligthert: "Re: Build new Access database from .NET application."
- Reply: Cor Ligthert: "Re: Build new Access database from .NET application."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|