Bonjour a tous,
Je suis entrain de développer un web service de partage de photo.
J'ai créer mon projet Web service ou j'ai codé mes classes et mes fonction.
Mais maintenant je n'arrive pas a construire mes objets dans le client.
Voici le code coté serveur
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53 Dim cxString As New SqlConnection("Data Source=JEROME-PC\SQLEXPRESS;Initial Catalog=MonAlbum;Integrated Security=True") <WebMethod(Description:=" Liste l'ensemble des proriété d'une table")> _ Public Function lister(ByVal table As String) As DataSet Dim myAdapter As SqlDataAdapter = New SqlDataAdapter Dim mydataSet As DataSet = New DataSet("MonAlbum") Dim myCommande As SqlCommand Try myCommande = New SqlCommand("SELECT * FROM " + table, cxString) myAdapter.SelectCommand = myCommande mydataSet.Clear() myAdapter.Fill(mydataSet) Return mydataSet Catch ex As Exception MsgBox(ex.Message) End Try Return mydataSet End Function <WebMethod(Description:=" Liste les element décrit dans la requete", EnableSession:=True)> _ Public Function listerAvecRequete(ByVal requete As String, ByVal table As String) As DataSet Dim myAdapter As SqlDataAdapter = New SqlDataAdapter Dim mydataSet As DataSet = New DataSet("MonAlbum") Dim myCommande As SqlCommand Try myCommande = New SqlCommand(requete, cxString) myAdapter.SelectCommand = myCommande mydataSet.Clear() myAdapter.Fill(mydataSet, table) Return mydataSet Catch ex As Exception End Try Return mydataSet End Function <WebMethod()> _ Sub supprimer(ByVal table As String, ByVal id As Integer) Dim cmd As New SqlCommand cmd.CommandType = CommandType.Text cmd = New SqlCommand("DELETE FROM " & table & " WHERE id = " & id, cxString) cmd.Connection = cxString cxString.Open() cmd.ExecuteNonQuery() cxString.Close() End Sub
Et voici le code coté client :
En gros comment faire pour utiliser un objet images de ma classe images
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 If Session("idNiveau") IsNot Nothing Then Me.literal_bienvenu.Text += "<div style=""font-size:25px;"">" Me.literal_bienvenu.Text += " Bienvenue " & Session("pseudoUser") Me.literal_bienvenu.Text += "</div>" Me.literal_bienvenu.Text += " Voici les photos de ta classe : " 'requete affiche les images avec un niveau supérerieur ou egale au niveau de l'utilisateur connecter ' la contrainte sur la visibilité est plus l' IdNiveau est faible plus la visibilité est faible ' ex : l'idNiveau 1 est l'administrateur Dim myImage As New image Dim mesphotos = myservice.listerAvecRequete("SELECT cheminMini FROM image WHERE idNiveau >= '" & Session("idNiveau") & "'", "image") Dim mesphotoXml = mesphotos.GetXml.ToString Try For Each item In mesphotoXml Me.literal_photo.Text += item.ToString Next Catch ex As Exception Me.literal_photo.Text = ex.Message End Try Else Me.literal_photo.Text = " erreur" End If
ne marche pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part Dim myImg as new image
Et de plus le item et sous format xml donc si je veut faire simplement :
ca ne marche pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part <img src="item"/>
Merci de votre aide
Partager