getting records in datatable


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: getting records in datatable

  1. #1
    Join Date
    Jul 2008
    Posts
    32

    getting records in datatable

    SQLSTR = "INSERT into temrp SELECT * FROM Table1 T" _
    & " LEFT JOIN PRDT P ON T.PID = P.PID" _
    & " JOIN CUSTOMER C ON T.CID= C.CID" _
    & " where month= '" & Month(dtpmonth.Value) & "' and year= '" & Year(dtpyear.Value) "


    Dim cmdAs New SqlCommand(SQLSTR, conn)
    rdr= cmdrpt.ExecuteReader()



    Dim table As New DataTable()
    table.Load(rdr)


    ?table.Columns.Count
    0
    ?table.Rows.Count
    0

    i getthe above results ib debug window but when i check thr' sqlquery analyser i get 3 records

    culd u let me knw whts missing that i am not able to get allthe 3 records in the table

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    You are using cmdAs as your SQL Command but cmdrpt as your reader.

    What is cmdrpt? Where is that defined? Not that it matters, I think if you do
    Code:
    Dim cmdAs New SqlCommand(SQLSTR, conn)
    Dim rdr As SqlDataReader = cmdAs.ExecuteReader()
    you will be better off.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Jul 2008
    Posts
    32
    Dim rdr As SqlDataReader

    SQLSTR = "INSERT into temrp SELECT * FROM Table1 T" _
    & " LEFT JOIN PRDT P ON T.PID = P.PID" _
    & " JOIN CUSTOMER C ON T.CID= C.CID" _
    & " where month= '" & Month(dtpmonth.Value) & "' and year= '" & Year(dtpyear.Value) "



    Dim cmd As New SqlCommand(SQLSTR, conn)
    rdr = cmd.ExecuteReader

    'cmd.ExecuteNonQuery()
    Dim table As New DataTable()
    table.Load(rdr)



    Dim ReportForm As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    ReportForm.Load(ReportName)
    ReportForm.SetDataSource(table)

    this is the whole code , sorry as there was some typing error frm my end

    here i have executed the reader and then populated a datatable

Similar Threads

  1. Replies: 4
    Last Post: 05-05-2008, 10:00 AM
  2. Replies: 0
    Last Post: 06-28-2007, 09:55 AM
  3. Replies: 0
    Last Post: 07-19-2002, 01:41 AM
  4. saving records in Access
    By Hian Chew in forum VB Classic
    Replies: 1
    Last Post: 03-28-2001, 12:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center