connection sql server avec objet ado.net
bonjour
j'essaye de me connecter a ma base de donné sqlserver 200avec l'objet sqlconnection
mais probléme ... ca ne marche pas du tout
j'ai trouver ce code sur msdn et l'ai adapté a mon projet
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub OpenSqlConnection()
Dim connectionString As String = GetConnectionString()
Using connection As New SqlConnection()
connection.ConnectionString = connectionString
connection.Open()
Console.WriteLine("State: {0}", connection.State)
Console.WriteLine("ConnectionString: {0}",connection.ConnectionString)
End Using
End Sub
Private Function GetConnectionString() As String
' To avoid storing the connection string in your code,
' you can retrieve it from a configuration file, using the
' System.Configuration.ConfigurationSettings.AppSettings property
Return "Data Source=(local);Database=App_Data/test.mdf;" & "Integrated Security=SSPI;"
End Function |
a la base la declaration de connection était :
Code:
Using connection As New SqlConnection()
mais visual web developer ne l'accepte pas et l'a corrigé
mais après cette correction
il écrit ceci : sqlexecption
que dois-je faire ????