drop down list and system.data.common.dbdatarecord

  • Thread starter Thread starter good will
  • Start date Start date
G

good will

sir
i m using a class function
public selectedrecord(byref tablename,byref column name,byref
condition)as odbcdatareader
steps
1)odbc connection
2)open
3)command =" select colname from table nae wher condition"

4)datareder=command.executereader
return reader
end sub


page_load()
1)
object for class
2)
dim dr as odbcdatareader= obj.selectrecord( parameters )
dropdownlist.datasource=dr
3)databing

but the erroe all system.data.common.dbdatarecord come in my drop down
list
 
DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a
property with the name description.

why does this error comes







Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


If Not Page.IsPostBack Then

Dim category As String
category = Request.QueryString("categoryname")
Me.Label1.Text = Request.QueryString("categoryname")
Dim obj As New dbclasses
Dim dr As Odbc.OdbcDataReader
dr = obj.selectrecord("description", "categories",
"category")
Me.dplist.DataSource = dr
Me.dplist.DataTextField = "description"
Me.dplist.DataValueField = " description"
dplist.DataBind()
End If

End Sub










Public Function selectrecord(ByRef cnames As String, ByRef tNAMEs As
String, ByRef condition As String) As OdbcDataReader


Dim con As New
OdbcConnection("PageTimeout=5;DSN=as;DriverId=281;DBQ=C:\Program
Files\Microsoft Office\Office\Samples\Northwind.mdb;FIL=MS
Access;UID=admin")
Dim cmd As New Odbc.OdbcCommand
Dim myreader As Odbc.OdbcDataReader
con.Open()
cmd.Parameters.Add(New OdbcParameter("tnames", cnames))
cmd.Parameters.Add(New OdbcParameter("name", tNAMEs))
cmd.Parameters.Add(New OdbcParameter("names", condition))

Dim strSQL As String

If cnames <> "" And condition <> "" Then
strSQL = "select ? from " & tNAMEs & " where ? "

ElseIf cnames <> "" And condition = "" Then
strSQL = "select " & cnames & " from " & tNAMEs
ElseIf cnames = "" And condition <> "" Then
strSQL = "select * from " & tNAMEs & _
" where " & condition
ElseIf cnames = "" And condition = "" Then
strSQL = "select * from " & tNAMEs
End If


cmd.CommandText = strSQL
cmd.Connection = con

myreader = cmd.ExecuteReader
Return myreader
con.Close()


End Function
 
DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a
property with the name description.

why does this error comes







Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


If Not Page.IsPostBack Then

Dim category As String
category = Request.QueryString("categoryname")
Me.Label1.Text = Request.QueryString("categoryname")
Dim obj As New dbclasses
Dim dr As Odbc.OdbcDataReader
dr = obj.selectrecord("description", "categories",
"category")
Me.dplist.DataSource = dr
Me.dplist.DataTextField = "description"
Me.dplist.DataValueField = " description"
dplist.DataBind()
End If

End Sub










Public Function selectrecord(ByRef cnames As String, ByRef tNAMEs As
String, ByRef condition As String) As OdbcDataReader


Dim con As New
OdbcConnection("PageTimeout=5;DSN=as;DriverId=281;DBQ=C:\Program
Files\Microsoft Office\Office\Samples\Northwind.mdb;FIL=MS
Access;UID=admin")
Dim cmd As New Odbc.OdbcCommand
Dim myreader As Odbc.OdbcDataReader
con.Open()
cmd.Parameters.Add(New OdbcParameter("tnames", cnames))
cmd.Parameters.Add(New OdbcParameter("name", tNAMEs))
cmd.Parameters.Add(New OdbcParameter("names", condition))

Dim strSQL As String

If cnames <> "" And condition <> "" Then
strSQL = "select ? from " & tNAMEs & " where ? "

ElseIf cnames <> "" And condition = "" Then
strSQL = "select " & cnames & " from " & tNAMEs
ElseIf cnames = "" And condition <> "" Then
strSQL = "select * from " & tNAMEs & _
" where " & condition
ElseIf cnames = "" And condition = "" Then
strSQL = "select * from " & tNAMEs
End If


cmd.CommandText = strSQL
cmd.Connection = con

myreader = cmd.ExecuteReader
Return myreader
con.Close()


End Function
 

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

Back
Top