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.

Empfohlene Antworten

Veröffentlicht

Ja Moin! 

Hab mir eben ein MSSQL Server aufgesetzt und bin mir nicht ganz sicher wie ich eine Verbindung zur Datenbank aufbaue.

Ich hab Windows Authentification gewählt. Es gibt also keinen "sa" Benutzer und kein pw.

 

Weis jemand wie ich das mache?

  • Autor
vor 8 Minuten schrieb KeeperOfCoffee:

Was genau ist jetzt die Frage?

Wie du ne Authentifizierung einreichtest? Wie du in einem Projekt mit der Datenbank arbeitest? Wenn ja, arbeitest du mit dem EF?

im prinzip wie ich eine datenbankverbindung mit VB.NET zu MSSQL aufbaue 

  • Autor
Zitat

Public Class Form1
    Dim sqlstatement As New SqlCommand
    Dim con = New SqlConnection("WA-MID01\SQLEXPRESS;Database=Test;User Id=***;Password=***")
    Dim dataReader As SqlDataReader


    Private Sub btnAutoren_Click(sender As Object, e As EventArgs) Handles btnAutoren.Click
        sqlstatement = New SqlCommand("Select * from Test.dbo.Autor", con)
        dataReader = sqlstatement.ExecuteReader()

        While dataReader.Read()
            txtboxAutoren.Text = "Datensatz: " + dataReader!Name
        End While

    End Sub
End Class
 

Klappt leider auch nicht. 

Da sagt mir der Compiler "System.ArgumentException: "Schlüsselwort wird nicht unterstützt: 'wa-mid01\sqlexpress;database'."

 

ich hab die SqlConnection durch:

Zitat

Dim con = New SqlConnection("Data Source=(local); initial Catalog=Test; Trusted_Connection=Yes;MultipleActiveResultSets=True")

ausgetauscht. Scheint immerhin die Connection erstmal zu akzeptieren. Werd gleich versuchen Zugriff auf die Daten der Db zu bekommen.

Bearbeitet von DieMstar

  • Autor
Zitat

Imports System.Data.SqlClient

Module Module1

    Sub Main()
        Dim con As SqlConnection
        con = databaseconnection()
        con.Open()

        Dim sqlDataReader As SqlDataReader
        Dim sqlCommand = New SqlCommand("SELECT * FROM Autor", con)
        sqlDataReader = sqlCommand.ExecuteReader()

        While sqlDataReader.Read()
            Console.WriteLine(sqlDataReader!Name)
        End While
        con.Close()
        Console.ReadKey()

    End Sub

    Function databaseconnection() As SqlConnection
        Const myConnectString As String = "Data Source=(local);Initial Catalog=Test;Trusted_Connection=Yes;MultipleActiveResultSets=True"
        Dim con As SqlConnection
        con = New SqlConnection(myConnectString)

        Return con
    End Function

End Module

ich bekomm einfach keinen Zugrif auf die DB. Keine Ahnung woran es liegen könnte ?

vor 12 Stunden schrieb DieMstar:

Da sagt mir der Compiler "System.ArgumentException: "Schlüsselwort wird nicht unterstützt:

Kein Wunder, der Connection String ist falsch, da fehlt vorn ein "Data Source=" bzw "Server=".
Wenn du nur Windows Authentification aktiv hast funktioniert es auch nicht Benutzer und Passwort zu übergeben, du benötigst "Integrated Security=SSPI;" oder "Integrated Security=true;"

vor 11 Stunden schrieb DieMstar:

Keine Ahnung woran es liegen könnte

ohne fehlermeldung schwer

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.