Click here to Skip to main content
16,007,932 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
C#
string query1st = "SELECT * FROM Registration_Master ";
                     com = new SqlCommand(query1st, con);
                     com.CommandType = CommandType.Text;
                     SqlDataAdapter da = new SqlDataAdapter(com);
                     DataTable dt1st = new DataTable();
                     da.Fill(dt1st);
                                          
                     if (dt1st.Rows.Count>0)
                     {


                     }

but this gives me wrong output

[Edit]Code block added[/Edit]
Posted
Updated 16-Nov-12 5:36am
v2
Comments
[no name] 16-Nov-12 11:39am    
Oracle, MYSQL or MSSQL?

1 solution

TSQL
SQL
SELECT TOP 1 * FROM Registration_Master

ORACLE (source[^])
If you want just a first selected row you can:
SQL
select fname from MyTbl where rownum = 1

you can also use analytic functions to order and take the top x
SQL
select max(fname) over (rank() order by some_factor) from MyTbl

MySQL
SQL
SELECT * FROM Registration_Master LIMIT 1;


If you want the latest record however, in each case you will have to order your records based on your primary key descending(or other column that can be sorted to provide the latest record)
 
Share this answer
 
v3

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