Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 21st, 2007, 01:10 AM
Authorized User
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default Extract data out from datareader


I have a problem here. I want to extract the details out for preparation to email these details out. However, when I use the datareader, everything turns weird. Below are my codes, please advice.

Dim selectedDate As DateTime
        Dim selectedCompany As String
        'Dim htmlcodes As String

        selectedDate = ddlDateCreated.SelectedValue
        selectedCompany = ddlCompany.SelectedValue.ToString

        MsgBox(selectedDate + " " + selectedCompany)

        Dim dbconn As OleDbConnection
        Dim sql As String
        Dim dbcomm As OleDbCommand
        Dim dataAdap As OleDbDataAdapter
        Dim ds As DataSet
        Dim dr As OleDbDataReader

        dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("App_Data/DB.mdb"))
        sql = "SELECT ID, acct, number, FullName FROM table WHERE comp LIKE '" + selectedCompany + "%'" + " and DateCreated LIKE '" + selectedDate + "%'"

        dbcomm = New OleDbCommand(sql, dbconn)

        dataAdap = New OleDbDataAdapter(dbcomm)

        ds = New DataSet
                    Ã‚  Â
            GridView1.DataSource = ds

            dr = dbcomm.ExecuteReader
            While dr.Read
                Dim account As String = dr("acct")
                Dim empno As String = dr("number")
                Dim name As String = dr("FullName")

                MsgBox(account + " " + empno + " " + name)
            End While

        Catch ex As Exception
            MsgBox("No records found for " + selectedCompany + " and of date " + selectedDate, MsgBoxStyle.OkOnly, "No Records Found")
        End Try

the datareader always ends with exception error even though there is a record existing in the data base.

Please advice me on which part of the codes I'm wrong in.
Thank you
Old September 21st, 2007, 07:27 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

hi there.. what error do you receive???, can you just change the generic exception to one that will tell you what the error is???



================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
================================================== =========
I know that CVS was evil, and now i got the proof:
================================================== =========

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can we update data through dataReader vedprakash4 ADO.NET 1 December 30th, 2007 12:27 PM
Extract data from memo field knix2007 Access VBA 7 December 17th, 2007 03:24 PM
How to extract certain data patterns from textbox method VB How-To 4 May 3rd, 2006 02:54 AM
DataReader brings back No data for Rows/Columns testsubject ADO.NET 13 January 16th, 2006 05:37 PM
Extract Data From Node ryanpatrick XML 1 February 18th, 2004 10:31 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.