Announcement

Collapse
No announcement yet.

Datenverwaltung in einzelne Dateien?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Datenverwaltung in einzelne Dateien?

    Hallo zusammen,

    ich arbeite schon etwa mit VB.Net und erstelle gerade ein kleines programm um meine Aufträge in der Firma zu Verwalten.

    Ist es möglich, für jeden Auftrag eine Datei anzulegen, in der die Daten gespeichert werden?

    z.B. sollen dort die Daten von verschiedenen Kunden (Kundenanfragen) hinterlegt werden, das entsprechende Angebot (muss auch geändert und ergänzt werden können), etc..

    Quasi wie eine SQL oder Access DB.
    Nur sollen diese Dateien dann in einem Explorer als "Auftrag xy" angezeigt werden.

    kann mir jemand helfen?

  • #2
    hallo,

    dazu würde mir XML einfallen, der Code der nachstehenden Klasse könnte eine Hilfe sein - ein Denkanstoß.
    ich verwende ihn dazu für jedes Formular einer Anwendung eine andere Datenquelle (ConnectionString) zuweisen und wieder auslesen zu können - wenn die Zuweisung geändert werden soll mußt du allerdings noch eigenen Code hinzufügen bzw den bestehenden ändern ;-)

    Gruß Christian

    Private Class clsConnOleDb
    Dim XwSettings As XmlWriterSettings
    Dim XrSettings As XmlReaderSettings
    Public Function fnXmlDocumentConConfigRead( _
    ByVal thisFormName As String, _
    ByVal XmlFileWithPath As String) _
    As String
    Debug.Print("")
    Debug.Print("fnOleDbConnStringAbfragen - Anfang")
    Dim xPdoc As XPathDocument
    Dim xNav As XPathNavigator
    Dim xIter As XPathNodeIterator
    fnXmlDocumentConConfigRead = ""
    Try
    If IsDBNull(XmlFileWithPath) Then
    Return fnXmlDocumentConConfigRead
    Else
    'Namespacemanager - Anfang
    Dim nsmgr As New XmlNamespaceManager(New NameTable())
    Dim ns As Collections.Generic.KeyValuePair(Of String, String)
    xPdoc = New XPathDocument(XmlFileWithPath)
    xNav = xPdoc.CreateNavigator
    xNav.MoveToRoot()
    If xNav.MoveToChild(XPathNodeType.Element) Then
    For Each ns In xNav.GetNamespacesInScope(XmlNamespaceScope.All)
    If ns.Key = "" Then
    nsmgr.AddNamespace("default", ns.Value)
    Else
    nsmgr.AddNamespace(ns.Key, ns.Value)
    End If
    Next
    End If
    'Namespacemanager - Ende
    xIter = xNav.Select("//xsi:Connection/xsi:Form", nsmgr)
    While xIter.MoveNext
    If Not IsDBNull(xIter.Current.Value) Then
    Select Case xIter.Current.Value.ToString
    Case thisFormName
    xNav = xNav.SelectSingleNode("//xsi:Connection/xsibPath", nsmgr)
    fnXmlDocumentConConfigRead = xNav.Value
    End Select
    Else
    Debug.Print("Fehler im System!")
    End If
    End While
    Return fnXmlDocumentConConfigRead
    End If
    Catch ex As System.IO.FileNotFoundException
    MessageBox.Show(ex.Message)
    End Try
    Debug.Print("fnOleDbConnStringAbfragen - Anfang")
    Debug.Print("")
    End Function
    Public Function fnXmlDocumentConConfigWrite(ByVal strConfigFileName As String, _
    ByVal strGuidConnection As String, _
    ByVal strForm As String, _
    ByVal strDbPath As String, _
    ByVal strDbProvider As String, _
    ByVal strDbProviderTyp As String) _
    As Boolean
    Debug.Print("")
    Debug.Print("fnXmlDocumentConConfigWrite - Anfang")
    Try
    Dim xdoc As New XmlDocument
    Dim xdocOfficeData As XmlAttribute
    Dim xdocSchemaInstance As XmlAttribute
    Dim xdocnoNamespaceSchemaLocation As XmlAttribute
    Dim xdocDeclaration As XmlDeclaration
    Dim eDataroot, _
    eConnection, _
    eGuidConnection, _
    eForm, _
    eDbPath, _
    eDbProvider, _
    eDbProviderTyp As XmlElement
    Dim aConnection As XmlAttribute
    'Document Declaration
    xdocDeclaration = xdoc.CreateXmlDeclaration( _
    "1.0", _
    System.Text.Encoding.UTF8.BodyName, _
    "no")
    xdoc.AppendChild(xdocDeclaration)
    'Root-Element
    eDataroot = xdoc.CreateElement("dataroot")
    xdoc.AppendChild(eDataroot)
    Try
    xdocOfficeData = xdoc.CreateAttribute("xmlnsd")
    xdocOfficeData.Value = "urn:schemas-microsoft-comfficedata".ToString
    xdocOfficeData.Value = eDataroot.Attributes.Append(xdocOfficeData).Value. ToString
    xdocSchemaInstance = xdoc.CreateAttribute("xmlns:xsi")
    xdocSchemaInstance.Value = "http://www.w3.org/2001/XMLSchema-instance".ToString
    xdocSchemaInstance.Value = eDataroot.Attributes.Append(xdocSchemaInstance).Va lue.ToString
    xdocnoNamespaceSchemaLocation = xdoc.CreateAttribute("noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance")
    xdocnoNamespaceSchemaLocation.Value = xdoc.DocumentElement.NamespaceURI.ToString + " " + "ApplicationConnectionConfig.xsd".ToString
    xdocnoNamespaceSchemaLocation.Value = eDataroot.Attributes.Append(xdocnoNamespaceSchemaL ocation).Value.ToString
    Catch ex As ArgumentException
    Debug.Print(ex.Message.ToString)
    MessageBox.Show(ex.Message.ToString)
    End Try
    'Element Connection
    eConnection = xdoc.CreateElement("Connection", "http://www.w3.org/2001/XMLSchema-instance")
    eDataroot.AppendChild(eConnection)
    'Attribut ConName Value = SteuerelementName
    aConnection = xdoc.CreateAttribute("ConName")
    aConnection.Value = strForm.ToString
    aConnection.Value = eConnection.Attributes.Append(aConnection).Value.T oString
    'Element GuidConnection
    eGuidConnection = xdoc.CreateElement("GuidConnection", "http://www.w3.org/2001/XMLSchema-instance")
    eGuidConnection.AppendChild(xdoc.CreateTextNode(st rGuidConnection.ToString))
    eConnection.AppendChild(eGuidConnection)
    'Element Form
    eForm = xdoc.CreateElement("Form", "http://www.w3.org/2001/XMLSchema-instance")
    eForm.AppendChild(xdoc.CreateTextNode(strForm))
    eConnection.AppendChild(eForm)
    'Element DbPath = DatenbankName und Verzeichnis-Pfad
    eDbPath = xdoc.CreateElement("DbPath", "http://www.w3.org/2001/XMLSchema-instance")
    eDbPath.AppendChild(xdoc.CreateTextNode(strDbPath) )
    eConnection.AppendChild(eDbPath)
    'Element DbProvider = Datenbank-Provider
    eDbProvider = xdoc.CreateElement("DbProvider", "http://www.w3.org/2001/XMLSchema-instance")
    eDbProvider.AppendChild(xdoc.CreateTextNode(strDbP rovider))
    eConnection.AppendChild(eDbProvider)
    'Element DbProvider
    eDbProviderTyp = xdoc.CreateElement("DbProviderTyp", "http://www.w3.org/2001/XMLSchema-instance")
    eDbProviderTyp.AppendChild(xdoc.CreateTextNode(str DbProviderTyp))
    eConnection.AppendChild(eDbProviderTyp)
    'Xml-Datei Speichern
    xdoc.Save(strConfigFileName)
    Catch ex As XmlException
    Debug.Print(ex.Message.ToString)
    MessageBox.Show(ex.Message.ToString)
    End Try
    Debug.Print("fnXmlDocumentConConfigWrite - Ende")
    Debug.Print("")
    End Function
    End Class


    im Anhang: xml-Datei mit xmlSchema dazu die Klasse

    Comment


    • #3
      im Anhang: xml-Datei mit xmlSchema dazu die Klasse
      ist nicht gleich mitgegangen, ....
      Attached Files

      Comment


      • #4
        Danke cb4866,

        cih werde das gleich mal ausprobieren.

        Comment

        Working...
        X