salut,

je veux créer une base sous sqlserver,via ADO.net et voici mon code ci dessous..
le problem est que j'ai une erreur lors de l'execution,et qui est la suivante:

l'exception COMexception n'a pas été gérée
[DBNETLIB][ConnectionOpen (Connect()).]Ce serveur SQL n'existe pas ou son accès est refusé.
verifiez la proprieté ErrorCode de l'exception pour determiner le Hresult de l'objet COM.


sachant que j'ai ajouté à mon projet deux references qui est le
Microsfot ActiveX Data Objects 2.8 Library
Microsoft OLE DB Service Component 1.0 Type Library

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
 
Imports ADODB
Public Class acceuil
 
    Dim Cnn_Connexion As New ADODB.Connection()
    Dim Cmd_CommandeSQL As New ADODB.command()
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Cnn_Connexion.Open("Provider=SQLOLEDB;server=SQLEXPRESS;UID=User;PWD=Password;database=ping;")
        Cmd_CommandeSQL.ActiveConnection = Cnn_Connexion
    End Sub
    Private Sub cmd_creation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_creation.Click
        Try
            Cmd_CommandeSQL.CommandText = "create table agence" & "(ip varchar(20)primary ke," & "agence_nom varchar(30)," & "localistation varchar(30)," & "adresse_mail varchar(30));"
            Cmd_CommandeSQL.Execute()
            Cmd_CommandeSQL.CommandText = "create table etat" & "(id_etat int primary key," & "ip varchar(20)refrences agence," & "etat varchar(10)," & "date datetime); "
            Cmd_CommandeSQL.Execute()
            MsgBox("les tables ont été crées !", MsgBoxStyle.Information, "resulat")
 
 
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
 
    Private Sub cmd_suppression_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_suppression.Click
        On Error Resume Next
        Cmd_CommandeSQL.CommandText = "drop agence"
        Cmd_CommandeSQL.execute()
        Cmd_CommandeSQL.commandText = "drop table etat"
        Cmd_commandeSQL.execute()
 
    End Sub
    Private Sub Form1_closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.closing
        Cnn_Connexion.Close()
    End Sub
 
End Class
quelqu'un aurait une idée ? merci d'avance