Probleme de lecture de champs BDD

S

sdffsdf

Bonjour,

je ne comprends pas pourquoi mon code ne fonctionne pas quand j'essaies de
recuperer le contenu d'un champ vide dans ma tables Access ...

'=== Description de la table

ID_Bloc ( INT numéo Auto clé primaire)
Code_Bloc (MEMO)
HREF_Image_Bloc ( Texte 50)
IMG_Bloc ( Texte 50)
Type_Paragraphe ( Texte 50)

'=== Fin de decription

Voici un morceau de mon code , merci de votre aide

ID_Bloc.Value = Request("ID_bloc")
Dim ObjConnection As OleDbConnection
Dim CS As String
CS = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath(".\databases\blocs.mdb") & " ;User Id=admin;Password=;"

ObjConnection = New OleDbConnection(CS)
ObjConnection.Open()
Dim strSQL As String

strSQL = "SELECT * FROM Blocs WHERE Id_Bloc=" &
Request("ID_Bloc")

Dim SQL As New OleDBCommand(strSQL, ObjConnection)

Dim liste As OleDBDataReader = SQL.ExecuteReader()

Try
ID_Bloc.Value = Request("ID_Bloc")
If liste("HREF_Image_Bloc") <> Nothing Then
HREF_Image.Text =
liste.GetString(liste.GetOrdinal("HREF_Image_Bloc"))
End If
HREF_Image.Text = liste("HREF_Image_Bloc")


Type_Paragraphe.Items.FindByValue(liste.GetString(liste.GetOrdinal("IMG_Posi
tion_Bloc"))).Selected = True
IMG_Bloc_Hidden.Value =
liste.GetString(liste.GetOrdinal("IMG_Bloc"))
IMG_Bloc.ImageUrl =
Liste.GetString(Liste.GetOrdinal("IMG_Bloc"))

Catch ex As Exception
Response.Write(ex.ToString)
Finally
ObjConnection.Close()
End Try

TOUS MES CHAMPS SONT DES CHAMPS "TEXTE" SAUF LE CHAMP : Code_Bloc
qui contient du code HTML encodé avec Server.htmlEncode() et qui se trouve
dans un champ MEMO

j'obtiens donc fatalement une erreur meme si j'utilise :

liste.GetString(liste.GetOrdinal("HREF_Image_Bloc"))
ou
liste.GetString(liste.GetOrdinal("Code_Bloc"))

voila l'erreur :

System.InvalidOperationException: Aucune donnée n'existe pour la
ligne/colonne. at System.Data.OleDb.OleDbDataReader.DoValueCheck(Int32
ordinal) at System.Data.OleDb.OleDbDataReader.GetValue(Int32 ordinal) at
System.Data.OleDb.OleDbDataReader.get_Item(String name) at
Applis.Edition.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\Applis\Edition.aspx.vb:line 76

Ceci dans le cas d'un champ vide ...

Mais quand tous les champs sont remplis , ca fonctionne très bien ..

Merci de Votre aide
 
K

Ken Cox [Microsoft MVP]

En passant, tu ferais mieux de poster en francais ici:

microsoft.public.fr.dotnet.aspnet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top