Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Visual Basic 2008 SQL Zugriff

Empfohlene Antworten

Veröffentlicht

Hallo AlleMitEinAnder =),

Ich versuche schon seit geraumer Zeit mich richtig von meinem guten altem VB 6 auf das neue VB 2008 umzugewöhnen.

Doch nun stehe ich wieder vor einem Problem.

Ich möchte mit meinem Tool auf eine SQL Datenbank (übers Internet) zugreifen und Datensätze ggf. ändern bzw. Tabellen hinzufügen.

Nur habe ich keine Ahnung wie ich das bewerkstelligen soll.

In VB008 gibts ja nur den DataGridView?!? Damit kann ich nicht viel anfangen, dar ich die Daten eher in textfelder, labels etc. haben möchte.

nach codeschnipseln habe ich schon gesucht, aber nichts passendes gefunden.

bitte um hilfe

mfg

radiohead

Hier mal ein beispiel für eine MSSQL Datenbank:


 Dim con As New Data.SqlClient.SqlConnection("Data Source=***; " & "Initial Catalog=***;" & "User ID=***;" & "Pwd=***")


 Dim cmd As New SqlClient.SqlCommand

        cmd.Connection = con

        cmd.CommandText = "Hier die Querry eintragen"

        Dim data As New SqlClient.SqlDataAdapter(cmd)

        Dim Data As New DataTable

        'Jetzt wird der Datatable mit den Daten, welche im Adapter zwischengespeichert wurden, "befüllt" .

        data6.Fill(Data)

Und die Daten kannst dir jetzt bequem aus dem Datatable holen.

Mfg

Gateway

hmm ich schaue dar nicht so durch,

die daten des servers (user etc.) sollen wohin?

zum ausprobieren hab ich lokal einen ms sql server 2008 laufen

wie soll ich darauf zugreifen?

mfg

radiohead

was inserts und updates angeht :


        Dim db_con As New SqlClient.SqlConnection(dein connection string)

        db_con.Open()


        Dim sc As New SqlClient.SqlCommand(sql, db_con)

        sc.ExecuteNonQuery()


        sc.Dispose()

        sc = Nothing

        db_con.Close()

        db_con.Dispose()

    End Sub
drauf zugreifen kannste auf deine Datatable ganz einfach, hier mal n beispiel wennd mit ner for schleife alle datensätze der Table durchgehen willst :

For each row as Datarow in tbl_xyz.Rows

     meinLable.text = row.item("irgendeineSpalte")

     meineTextbox.text = row.item("andereSpalte")

next

Bearbeitet von streffin

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.