Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
meandgon
Starting Member
5 Posts |
Posted - 2008-04-20 : 22:57:53
|
Why is it my number of records are different from my view. this are the following code that that i used in my code and in my view.my code in my program: this code show all the records i know If iConn.State = ConnectionState.Open Then iConn.Close() iConn.Open() Dim rsBills As New Data.DataSet rsBills = New DataSet Dim daBills As New SqlDataAdapter daBills = New SqlDataAdapter rsBills.Clear() Dim cmBills As New SqlCommand cmBills = iConn.CreateCommand ' "Select U_Code, U_Name, U_Level, P_Word From EPassword ", cmBills.CommandText = "Select OR_no, Billing_mo From dbo.vwBilling Where Month(dbo.vwBilling.Billing_mo)= " & Month(Me.dtto.Value) & " And Year(dbo.vwBilling.Billing_mo) = " & Year(Me.dtto.Value) & " ORDER BY OR_no " daBills.SelectCommand = cmBills rsBills.AcceptChanges() rsBills.Clear() daBills.Fill(rsBills, "Bills") Me.DataGridView1.DataSource = Nothing Me.DataGridView1.DataSource = rsBills.Tables("Bills")my code in views:SELECT OR_no, Billing_mo, Account_no, Name, Address, Cno, Pres_read, Mprev_read, Sub_read, Pres2, Prev2, SRead2, Mtr_cons, Amount, NPC, Dmem, Cmem, Tot_bill, D_Pmnt, Class, Newbill, Prd_fr, Prd_to, Type_Pmnt, Type_Date, Type_Docs, wtaxFROM dbo.Billinghope you can help me guys |
|
rlaubert
Yak Posting Veteran
96 Posts |
Posted - 2008-04-30 : 10:36:09
|
Not sure what you are asking, but I am going to assume that you want to know why your code (program) returns a different number of records from your view. If that is the case, the answer is simple. The view has no where clause so it will return all records. The program is using a where clause which will limit the number of records being returned to just those that meet your requirements, in this case, month that you are viewing (where month(dbo.vwbilling.billing_mo = etc)).Raymond LaubertMCITP:Administration, MCThttp://www.rd-webhosting.comHome Based Business Library and Hosting |
|
|
|
|
|
|
|