MySQL "SELECT TOP x * FROM" question

EFileTahi-A

Well-known member
Joined
Aug 8, 2004
Messages
539
Location
Portugal / Barreiro
Am trying to select only one row from a specific table, the problem is that I just cant make it work. I tryed the following:

SELECT TOP 1 * FROM tablename
SELECT TOP (1)* FROM tablename
SELECT TOP 1 FROM tablename
SELECT TOP (1) FROM tablename

But it always end up with:
An unhandled exception of type Microsoft.Data.Odbc.OdbcException occurred in system.data.dll

Additional information: System error.

When I try to fill an DataTable...


Code:
public System.Data.DataTable InDocLin(int iHowMany)
{
	if (iHowMany  == 0){sSQL = "SELECT * FROM InDocLin";}
	else {sSQL = "SELECT TOP (" + iHowMany + ") * FROM InDocLin";}
	OdbcDataAdapter daTemp = new OdbcDataAdapter(sSQL, MyConnData);
	System.Data.DataTable dtTemp = new System.Data.DataTable(); daTemp.Fill(dtTemp);
	return dtTemp;
}

SELECT * FROM tablename <--- this works fine, so the connection and table are ok...
 
Last edited by a moderator:
Back
Top