Exaray work areas
Exaray Logo
Home arrow Visual Basic arrow Code Snippets arrow Database Operations
Hauptmenue
Home
Wissen
Visual Basic
News
Downloads
Links
Suche
Administratives
Impressum & Kontakt
Disclaimer
Login





Passwort vergessen?
Noch kein Benutzerkonto?
Registrieren

Keine Zugangsdaten?
Einfach anfordern unter webmaster@exaray.com
Newsflash

Die neue Serverkonfiguration ist online!
Die folgenden Online-Dienste stehen ab sofort zur Verfügung...

weiter …
 

Unser neuer Exchange-Server ist ab sofort auf Exaray umgestellt!

weiter …
 

Unser neuer Asterisk-Server ist ab sofort auf Exaray umgestellt!

weiter …
 
Database Operations PDF Drucken E-Mail
Geschrieben von Lindner Wolfhard   
Friday, 13. March 2009
'Vorbereitungsarbeiten:
'
'Menü "Daten" - "Neue Datenquelle hinzufügen"
'Table Adapter auf Formular ziehen
'Data Set auf Formular ziehen

Public Class frmDatabase
    Private Sub subMountDatabase()
        Try
            'Open Table Adapter (filename is predefined in the connection string - Resources)
            tblXYZTableAdapter.Connection.Open()
        Catch ex As Exception
            MsgBox("The connection to the Database 'C:\Database.accdb' failed." & ControlChars.CrLf & "Please make sure that the database exists and the file is not corrupted.", MsgBoxStyle.Critical, "Database error")
        End Try
    End Sub

    Private Sub subDismountDatabase()
        Try
            'Close Table Adapter
            tblXYZTableAdapter.Connection.Close()
        Catch ex As Exception
            MsgBox("The connection could not be closed", MsgBoxStyle.Critical, "Database error")
        End Try
    End Sub
   
    Private Sub subSearchDatset
        Dim rowFound As DataRow()
        Dim strSearchTerm As String
        Dim strFieldContent As String

        'Fill DataSet with a specific Table from the Database
        tblXYZTableAdapter.Fill(Database_XYZDataSet.tblTABLE)

        'Find a certain Row in the DataSet and write it to the rowFound variable
        'FIELD1 = name of the data field
        'strSearchTerm = the thing you are searching for
        rowFound = Database_XYZDataSet.tblTABLE.Select("FIELD1 = '" & strSearchTerm & "'")

        'Write the content of a certain field in the row we have just found to the strFieldContent variable
        strFieldContent = rowFound(0).Item("FIELD1").ToString
    End Sub

    Private Sub subAddDataset
         Dim rowNew As DataRow

         'Schema definieren
         rowNew = Database_XYZDataSet.tblTABLE.NewRow

         rowNew.Item("FIELD1") = "string1"
         rowNew.Item("FIELD2") = "string2"

         Database_XYZDataSet.tblTABLE.Rows.Add(rowNew)
         tblXYZTableAdapter.Update(Database_XYZDataSet)
    End Sub
End Class

Letzte Aktualisierung ( Friday, 13. March 2009 )
 
< zurück   weiter >
   design-cibox.de