Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all !!!

please tell me what does 0.0 and 0 signifies in the below query. I googled it but was unable to find the answer.


"Select 0.0 gpf_Contribution, 0.0 Advance_return, 0.0 Total, 0.0 Advance_return_amt, 0.0 progressive, 0 month_num where 1=2"
Posted
Comments
Sergey Alexandrovich Kryukov 29-May-12 1:02am    
Select FROM what?
--SA
ujjwal uniyal 29-May-12 1:15am    
I am puzzled too that from what it is selecting from. I am working on some other guy's project who left the company. Now this is called on page load. it's a very long function . here is a small part of it
here fn is the financial year

Private Sub sbBindReport(ByVal eid As String, ByVal fn As String)
On Error Resume Next
Dim ds As New ds_GPFReport()
'' ''
Dim frm_x As String = "01-Apr-" + fn.Substring(0, 4)
Dim frm_y As String = "31-Mar-" + fn.Substring(5, 4)

'' ''Blank Main Datatable
Dim x As String = "Select 0.0 gpf_Contribution, 0.0 Advance_return, 0.0 Total, 0.0 Advance_return_amt, 0.0 progressive, 0 month_num where 1=2"
Dim da As New SqlDataAdapter(x, ConfigurationManager.ConnectionStrings("PIMSConnectionString").ConnectionString)
da.Fill(ds, "gpf")
'' ''Copy of main
Dim dt_copyOfMain As New DataTable()
dt_copyOfMain = Dal.GettDS(x).Tables(0)

'' ''GPF Details
x = "Select GPF_monthly_cont, month(GPF_monthly_cont_start_dt) month_num ,GPF_monthly_cont_start_dt,GPF_monthly_cont_end_dt "
x += " from details_gpf_gis"
x += " where empid=" + eid + " and GPF_monthly_cont_start_dt between '" + frm_x + "' and '" + frm_y + "'"
x += " order by month_num"

Dim dt_gpfDets As New DataTable
dt_gpfDets = Dal.GettDS(x).Tables(0)

here is Dal.GettDS(string x)

Public Overloads Shared Function GettDS(ByVal str As String) As Data.DataSet
Dim conn As New SqlConnection(conMain)
Dim cmd As New SqlCommand
Dim ds As New Data.DataSet
cmd.CommandText = str
cmd.Connection = conn
conn.Open()
cmd.CommandType = Data.CommandType.Text
Dim da As New SqlDataAdapter
da.SelectCommand = cmd
da.Fill(ds, "table1")
cmd.Dispose()
conn.Close()
conn.Dispose()
Return ds
End Function
Sebastian T Xavier 29-May-12 1:45am    
This query will not show error even if it doesn't have FROM. Am I right?

1 solution

HI,

This query will NOT give any result, as your where condition never become TRUE.

If you remove your where condition you will get the following result.

gpf_Contribution Advance_return  Total  Advance_return_amt   progressive  month_num
   0.0               0.0          0.0       0.0                 0.0           0    


I hope you are clear.

Regards
Sebastian
 
Share this answer
 
v2
Comments
ujjwal uniyal 29-May-12 1:06am    
the where condition is given later in another query which are then filling a dataset (.xsd). And it's working fine. but i am unable to understand what 0.0 & 0 signifies here..
ujjwal uniyal 29-May-12 1:10am    
Ok. thanks Sabastian :)
Sergey Alexandrovich Kryukov 2-Jul-12 16:25pm    
Good catch, my 5.
--SA
Sebastian T Xavier 3-Jul-12 0:15am    
Thanks SA :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900