Click here to Skip to main content
16,011,757 members
Home / Discussions / Database
   

Database

 
AnswerRe: Problem in inserting the same number????? Pin
blackjack215014-May-07 21:45
blackjack215014-May-07 21:45 
AnswerRe: Problem in inserting the same number????? Pin
mamirbalouch15-May-07 1:34
mamirbalouch15-May-07 1:34 
GeneralRe: Problem in inserting the same number????? Pin
chand1015-May-07 19:22
chand1015-May-07 19:22 
Questionsetup file Pin
kanth_2ma214-May-07 14:33
kanth_2ma214-May-07 14:33 
AnswerRe: setup file Pin
kubben14-May-07 16:14
kubben14-May-07 16:14 
QuestionInserting into oracle table from a Data table...how to do in C# Pin
bnathvbdotnet14-May-07 13:47
bnathvbdotnet14-May-07 13:47 
QuestionProblem with query and datareader [modified] Pin
kallileo14-May-07 7:01
kallileo14-May-07 7:01 
AnswerRe: Problem with query and datareader Pin
Colin Angus Mackay14-May-07 11:18
Colin Angus Mackay14-May-07 11:18 
Have you thought about using ExecuteScalar instead of ExecuteReader? ExecuteScalar is used when you only want to retrieve the first column of the first row of the result set (typically when yours select only retrieves one row with one column in in)

Also, I suspect that your second query is returning zero rows. You don't check for the condition of no data being returned, hence the error. Using ExecuteScalar will remove the error and return null if no data is being returned from the query instead of throwing an error.

In order that the query returns data, I'm guessing that you want the condition of the MAX timestap AND the name. You need to specify the name twice, once inside the subquery and once outside it.


kallileo wrote:
SELECT MAX(timestamp) FROM [datastore]) AND name='s1'


This is just the subquery on its own. It should be easier to spot WHERE the error is.

The full query should be:
SELECT [rawvalue] 
FROM [datastore] 
WHERE timestamp=((SELECT MAX(timestamp) FROM [datastore]) WHERE name='s1') 
AND name='s1'



Upcoming events:
* Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services...

Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton


My website

GeneralRe: Problem with query and datareader Pin
kallileo14-May-07 11:24
kallileo14-May-07 11:24 
GeneralRe: Problem with query and datareader Pin
Colin Angus Mackay14-May-07 11:26
Colin Angus Mackay14-May-07 11:26 
GeneralRe: Problem with query and datareader Pin
kallileo14-May-07 11:36
kallileo14-May-07 11:36 
GeneralRe: Problem with query and datareader Pin
Colin Angus Mackay14-May-07 11:40
Colin Angus Mackay14-May-07 11:40 
GeneralRe: Problem with query and datareader Pin
kallileo14-May-07 12:22
kallileo14-May-07 12:22 
QuestionRerun access formwizard [modified] Pin
Dan Neely14-May-07 4:25
Dan Neely14-May-07 4:25 
AnswerRe: Rerun access formwizard Pin
Dave Kreskowiak14-May-07 12:36
mveDave Kreskowiak14-May-07 12:36 
QuestionReadonly Forms in Acess Pin
Dan Neely14-May-07 4:24
Dan Neely14-May-07 4:24 
AnswerRe: Readonly Forms in Acess Pin
Paul Conrad14-May-07 7:26
professionalPaul Conrad14-May-07 7:26 
QuestionINSERT performanse (ODBC to MS SQL) Pin
_TLS14-May-07 4:15
_TLS14-May-07 4:15 
AnswerRe: INSERT performanse (ODBC to MS SQL) Pin
Dave Kreskowiak14-May-07 5:13
mveDave Kreskowiak14-May-07 5:13 
AnswerRe: INSERT performanse (ODBC to MS SQL) Pin
andyharman14-May-07 6:01
professionalandyharman14-May-07 6:01 
QuestionDatabinding using the BindingNavigator Control Pin
Quecumber25614-May-07 3:20
Quecumber25614-May-07 3:20 
AnswerRe: Databinding using the BindingNavigator Control Pin
Muhadeeb9914-May-07 3:37
Muhadeeb9914-May-07 3:37 
QuestionMSDE File size limits Pin
Not Active14-May-07 2:23
mentorNot Active14-May-07 2:23 
AnswerRe: MSDE File size limits Pin
kubben14-May-07 4:04
kubben14-May-07 4:04 
GeneralRe: MSDE File size limits Pin
Not Active14-May-07 4:19
mentorNot Active14-May-07 4:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.