Click here to Skip to main content
15,907,236 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.....
My query not fetching Date column from Mysql Databse.and not showing 'date column' on gridview. Mysql command is like this:
SQL
select p.sno as RecieptNo,p.feesamount,p.totalpaid,p.dueamount,p.`paymentdate`,p.paymode,p.bank,p.checkno,p.status  from paymentdetails p,studentdetails s where p.sid=s.sid and s.class='" + DropDownList2.SelectedValue + "' and s.division='" + DropDownList3.SelectedValue + "' and s.rollno='" + DropDownList4.SelectedValue + "'  order by p.sno

Can any one please help me.
Thanks in advance.
Posted
Updated 6-Mar-11 19:56pm
v3
Comments
Sunasara Imdadhusen 7-Mar-11 1:59am    
why are you enclosed payment date to quotation e.g. p.`paymentdate`
tulasiram3975 7-Mar-11 2:01am    
i tried in many ways like this way also. in order to escape from predefined keywords

Firstly: remove the quotation marks from the field names list: it won't help.

Secondly: Check you have a column called paymentdate in your paymentdetails table, and that it is a date format column.

Thirdly: Check you have data in the column.

If all the above are OK, we need to see the code fragment where you use the SELECT statement.
We also need any error messages, etc., that you get.

"i removed quotation, had column in table and is a Date DataType third one is i had more than 30 columns but it won't work my code is:
MySqlDataAdapter da = new MySqlDataAdapter("select p.sno as RecieptNo,p.feesamount,p.totalpaid,p.dueamount,p.paymentdate,p.paymode,p.bank,p.checkno,p.status  from paymentdetails p,studentdetails s where p.sid=s.sid and s.class='" + DropDownList2.SelectedValue + "' and s.division='" + DropDownList3.SelectedValue + "' and s.rollno='" + DropDownList4.SelectedValue + "'  order by p.sno", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
remaining all columns coming into gridview except paymentdate
no error message while showing output
thank you"


Odd. Try cutting the select statement down to the minimum:
SQL
select p.sno, p.paymentdate from paymentdetails p
and see what happens (this is just trying to work out where the problem is, not fix it yet - so comment out you existing SELECT, you will need it again!)

If this works, try re-inserting elements a few at a time until it goes wrong.

"if i use this query(select p.sno, p.paymentdate from paymentdetails p) then i get only sno date column not coming"

Take out "p.sno":
SQL
select paymentdate from paymentdetails
Get any columns?
 
Share this answer
 
v3
Comments
tulasiram3975 7-Mar-11 2:44am    
i removed quotation, had column in table and is a Date DataType third one is i had more than 30 columns but it won't work my code is:
MySqlDataAdapter da = new MySqlDataAdapter("select p.sno as RecieptNo,p.feesamount,p.totalpaid,p.dueamount,p.paymentdate,p.paymode,p.bank,p.checkno,p.status from paymentdetails p,studentdetails s where p.sid=s.sid and s.class='" + DropDownList2.SelectedValue + "' and s.division='" + DropDownList3.SelectedValue + "' and s.rollno='" + DropDownList4.SelectedValue + "' order by p.sno", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
remaining all columns coming into gridview except paymentdate
no error message while showing output
thank you
OriginalGriff 7-Mar-11 3:34am    
Answer updated
tulasiram3975 7-Mar-11 5:24am    
am really sorry,
i got an error from this query(select paymentdate from paymentdetails)
error is:
The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content.
OriginalGriff 7-Mar-11 5:38am    
Yes, I'm still thinking. All this implies that the column is non-existant, but then why isn't the database / DataAdapter giving an error...?
tulasiram3975 7-Mar-11 5:47am    
But sir, Remaining All Columns coming into gridview e.g:select sid from paymentdetails works fine sid coming. the only problem is date please help me sir ...
thank you
I found Solution sir....
special thanks to you 'OriginalGriff', you are tried a lot
Solution is :
XML
<Columns>
     <asp:BoundField HeaderText="RecieptNo" DataField="sno" />
    <asp:BoundField HeaderText="Amount" DataField="feesamount"  />
   <asp:BoundField HeaderText="Paid" DataField="totalpaid" />
   <asp:BoundField HeaderText="Due Amount" DataField="dueamount"  />
  <asp:BoundField HeaderText="Date(M/D/YY)" DataField="paymentdate" />
    <asp:BoundField HeaderText="PaymentMode" DataField="paymode" />
    <asp:BoundField HeaderText="Bank" DataField="bank" />
    <asp:BoundField HeaderText="CheckNo" DataField="checkno"/>
   <asp:BoundField HeaderText="Status" DataField="status" />
</Columns>

in this way i am getting date column also.
 
Share this answer
 
v2

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