Bonjour à tous,

Voilà je passe de VBA à VB.net donc je suis des plus débutants possible...

J'ai créé une base de donnée SQL via Visual Studio sans aucun soucis j'ai remplis des champs et tout mais pour me connecter j'ai un petit soucis. Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
Imports System
Imports System.Data.SqlClient
 
Module apiSearchDB
 
    'Renvois de la valeur SX correspondant à searchVal
    Function searchSXGrid(searchVal As String) As Double
        searchSXGrid = 0
 
        Dim SQLConxtion As SqlConnection = New SqlConnection("Data Source=(LocalDB)\\v11.0;Initial Catalog=C:\USERS\JEANRAAD\DESKTOP\HOLCIM QUALITY SOLUTIONS\VB.NET\HQS\HQS\BIN\DEBUG\HQSDB.MDF;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;")
 
        Try
            SQLConxtion.Open()
        Catch myerror As SqlException
            MsgBox("Error connection SQL")
            SQLConxtion.Close()
            Exit Function
        End Try
 
        Dim myAdapter As New SqlDataAdapter
 
        Dim sqlquery = "SELECT * FROM dbo.SXGrid WHERE Id = '" + searchVal + "';"
        Dim myCommand As New SqlCommand()
        myCommand.Connection = SQLConxtion
        myCommand.CommandText = sqlquery
 
        myAdapter.SelectCommand = myCommand
        Dim myData = myCommand.ExecuteReader()
 
        If myData.Read Then
            searchSXGrid = myData.GetString("Value")
        End If
        myData.Close()
        SQLConxtion.Close()
 
    End Function
 
End Module
Mais voilà j'ai le message d'erreur qui s'affiche à chaque fois...
Est-ce que je dois d'office me connecter à ma base de donnée HQSdb et si oui comment?
Sinon est-ce que je peux y accéder autrement?

Merci d'avance