Hi,
Maybe we are thinking differently. My function already returns all the
records according to error_code.
I used inserted a datagrid on my aspx page and the record is displayed.
I send you my drMessage function which returns the record:
Function drMessage(ByVal message_code As String) As
System.Data.IDataReader
Dim connectionString As String =
System.Configuration.ConfigurationSettings.AppSett ings("connectionString")
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT [t_4web_message].* FROM
[t_4web_message] WHERE ([t_4web_message].[message_"& _
"code] = @message_code)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_message_code As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_message_code.ParameterName = "@message_code"
dbParam_message_code.Value = message_code
dbParam_message_code.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_message_code)
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
So when I do drMessage("404") I get the right record.
Now instead of displaying all fields in a dataset I just want to make
access one of the fields to use as an imageURL and the other field to
use as text message.
Thanks,
Miguel
"srini" <srini@discussions.microsoft.com> wrote in message
news:srini@discussions.microsoft.com:
[color=blue]
> hi,
> datareader always holds only one record. and when you say
> drMessage(error_code) its actually looking for a column with column name
> [error_code] which is obviously not there. you have to loop through the
> records in the datareader to check for the record corresponding to that error
> code. instead why dont you consider sending the [error code] in the query or
> storedproc and get the corresponding record(filter at the database itself).
> --
> HTH
> srini
>
http://www.expertszone.com
>
>
> "Shapper" wrote:
>
>[color=green]
> > Hello,
> >
> > I am using this:
> > drMessage(error_code).Item("icon_URL").ToString()
> >
> > I get the error:
> > System.InvalidOperationException: No data exists for the row/column.
> >
> > I tested the datareader and it's working fine.
> > The variable error_code filters the right record.
> >
> > What is wrong here?
> >
> > Thanks,
> > Miguel
> >
> > "srini" <srini@discussions.microsoft.com> wrote in message
> > news:srini@discussions.microsoft.com:
> >[/color]
>[color=green][color=darkred]
> > > try using
> > > myImage.ImageURL =dr.Item("imageURL").ToString()
> > > myImage.Text = dr.Item("message").ToString()
> > >
> > > where dr is your datareader.
> > >
> > > --
> > > HTH
> > > srini
> > >
http://www.expertszone.com
> > >
> > >
> > > "Shapper" wrote:
> > >
> > >[/color][/color]
>[color=green][color=darkred]
> > > > Hello,
> > > >
> > > > I have created a datareader function in a asp.net/vb web site.
> > > >
> > > > The datareader returns only one record with 2 fields:
> > > > [message] and [imageURL]
> > > >
> > > > In the same aspx.vb I want to use this values as follows:
> > > > myImage.ImageURL = [ image URL ]
> > > > myImage.Text = [ message ]
> > > >
> > > > How can I do this?
> > > >
> > > > Thanks,
> > > > Miguel
> > > >
> > > >[/color]
> >[/color]
>[color=green]
> >[/color][/color]