Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string sql1 = "Select * from callpad_def where read_status=@read ORDER BY time_stamp DESC";
SqlCommand cmd = new SqlCommand(sql1, con);
SqlDataReader sqlReader = cmd.ExecuteReader();
while (sqlReader.Read())
{
    c_address =Convert.ToInt32(sqlReader.GetValue(0).ToString());
    c_status = sqlReader.GetValue(1).ToString();
    token_no = (sqlReader.GetValue(2).ToString());
    if (c_status != null)
    {
        status_reader(c_status);
    }
}
sqlReader.Close();
Posted
Updated 31-May-13 1:36am
v3
Comments
Sushil Mate 31-May-13 1:47am    
whats read? variable or string?
Pradip Jadhav, India 31-May-13 1:51am    
Status string

You need to write query such as

C#
"Select * from callpad_def where read_status=" + 'read' + "ORDER BY time_stamp DESC"
 
Share this answer
 
v2
Modify your query such as,

here read is a variable so you passed its value like this way..

"Select * from callpad_def where read_status=" + read + "ORDER BY time_stamp DESC";

Thanks

Happy coding...
 
Share this answer
 
v2
String readValue;
string sql1 = "Select * from callpad_def where read_status=@read ORDER BY time_stamp DESC";
                SqlCommand cmd = new SqlCommand(sql1, con);
                cmd.Parameters.AddWithValue("@read", readValue);
                SqlDataReader sqlReader = cmd.ExecuteReader();
                while (sqlReader.Read())
                {
                    c_address =Convert.ToInt32(sqlReader.GetValue(0).ToString());
                    c_status = sqlReader.GetValue(1).ToString();
                    token_no = (sqlReader.GetValue(2).ToString());
                    if (c_status != null)
                    {
                        status_reader(c_status);
                    }
                }
                sqlReader.Close();
 
Share this answer
 
var result = cdo.order_histories
.Where(oh => oh.order_id == 20119)
.OrderByDescending(oh => oh.date_inserted)
.Take(1)
.Select(oh => new {history = oh, order = oh.order}
.Single();




Kishor Makwana
Software Engineer
Insight Softech
www.insightsoftech.com
 
Share this answer
 

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