Thursday 15 April 2010

vb.net - Not able read the next record using datareader -


I want to retrieve data from several tables and create a crystal report. So I have created a new table and enter the value each time I need to prepare a report. So I'm using the following code to retrieve data from those tables

code:.

  private sub gen_Report () Dim dr, DR1, DR2 OleDb.OleDbDataReader as dim Cmd, cmddel, comm_inv1, comm_invuser as oledb.OleDbCommand If cnnOLEDB.State = ConnectionState.Closed then cnnOLEDB. CmdDel = New OleDb.OleDbCommand (strDelInsRp, cnnOLEDB) CmdDel.Parameters.AddWithValue ("@ chlno", cmbChal_no.Text) cmdDel.ExecuteNonQuery as Open strings = ("Delete from Inst_Report") if dim (if end) end strdelInsRp string = string = ( "SELECT * fROM installation_det where Chalan_No = @ chlno") cmd = new OleDb.OleDbCommand (strSelIns, cnnOLEDB) as CMD dim strSelIns .Parameters.AddWithValue ( "@ chlno", cmbChal_no.Text) Dr = cmd. Try ExecuteReader while dr.Read = true mach_srno = dr ("machine_SrNo") tft_srno = dr ("tFT_SrNo") chl_no = Dr ( "Chalan_No") usernm = Dr ( "USER_NAME") ins_dt = Dr ( "Date_Of_Installation") war_perd = Dr ( "Warranty_Period") war_till = Dr ( "Warranty_Valid_Till") and = ( "invoices as dim strSelInv1 string Select * _ONE where LAY_NO = 'VDC' and CHL_NO = @ chn_no ") comm_inv1 = new OLEDB. Ondebee Command (Streisel INV 1, CNNOEldB) comm_inv1. Parameter. Advet value ( "@ Sianano" Sielelo) Drl = Com_invi L.aksakyut reader if dr1.Read = true then doc_no = DR1 ( "DOCU_NO") = DR1 ( "CODE_NO") memb_nm = DR1 ( "MEMB_NM") Dim strSelInvUser code_no As string = ("Choose from INVOICE_USER * where CODE_NO = @ code and LAY_NO = 'Village Defense Committee' and 'DOCU_NO = @ Docno") comm_invuser = New OleDb.OleDbCommand (strSelInvUser, cnnOLEDB) comm_invuser.Parameters.AddWithValue ("@ code ", code_no) comm_invuser.Parameters.AddWithValue (" @ docno ", doc_no) dr2 = comm_invuser.ExecuteReader If dr2.Read = truth User_add = dr2 (" ILEN2 ") & amp; Dr2 ("ILEN3") & amp; Dr2 ("ILEN4") & amp; DR2 ( "ILEN5") finally dr2.Close () finished dr1.Close () Dim strInsRep As String = "include Inst_Report (Mach_srNo, TFT_srNo, Mem_nm, UserNm, Dt_Inst, War_Per, war_till, User_Address) values ​​( @mach_srno, @ttt_no, @mm_nm, @Unem, @Insta_DT, @world_uper, @warm_teal, @ address) "Dim Com_in's Arp Olebey Oleadby Comand = New Ole DB Ondebee Command (Strings Rip, CNNOLDDB) Comm_INSRP. Parameter. Edvat Value ("@Ipisarrow" Mach_srno) comm_InsRep.Parameters.AddWithValue ("@tft_no", tft_srno) comm_InsRep.Parameters.AddWithValue ("@ mem_nm", memb_nm) comm_InsRep.Parameters.AddWithValue ("@ uname", usernm) comm_InsRep Parameters.AddWithValue ("@ inst_dt", Ins_dt) comm_InsRep.Parameters.AddWithValue ("@ war_per", war_perd) comm_InsRep.Parameters.AddWithValue ("@ war_till", war_till) comm_InsRep.Parameters.AddWithValue ("@ address", User_add) Comm_InsRep.ExecuteNonQuery () Loop Dr.Close () Pre-Exception Try Exception MsgBox (ex.Message) End As End Sub   

But the problem is that if DataReader only I Reads for the first record using 'Louis Loop' Lue m

A second question to me:

As a large number of fields I want to make a report in landscape orientation. So how to change the orientation of the report.

I am using Visual Studio 2005 and MS Access 2007 and programming language VB.NET.

After

Regarding your data, I believe that the standard for receiving data from an OleDbDataReader To use this method is to fill a datatable, try this:

  GetDataTableUsingDataReader (ByVal Order as OleDbCommand) DataTable DataTable as DataTable = New DataTable Use OleDbDataReader = command.ExecuteReader dataTable.Load Reader as in the form (Reader, LoadOption.OverwriteChanges) Expiration Return DataTable End Function   To get your crystal report on landscape, right click on the report in Designer, Goto Design = & gt; page Setup. From here you can change the orientation.   

No comments:

Post a Comment