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

Database

 
AnswerRe: Problem in inserting the same number????? Pin
srktirumala14-May-07 18:39
srktirumala14-May-07 18:39 
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 
Dim SelectCmd1 As New SqlCommand("SELECT [rawvalue] FROM [datastore] WHERE timestamp=(SELECT MAX(timestamp) FROM [datastore]) AND name='s1'", SQLconn)
SelectCmd1.CommandType = CommandType.Text
Dim result1 As Integer
Dim myDataReader1 As SqlDataReader
myDataReader1 = SelectCmd1.ExecuteReader()
myDataReader1.Read()
result1 = myDataReader1.GetInt32(0)
SQLconn.Close()

SQLconn.Open()
Dim SelectCmd2 As New SqlCommand("SELECT [rawvalue] FROM [datastore] WHERE timestamp=(SELECT MAX(timestamp) FROM [datastore]) AND name='s2'", SQLconn)
SelectCmd2.CommandType = CommandType.Text
Dim result2 As Integer
Dim myDataReader2 As SqlDataReader
myDataReader2 = SelectCmd2.ExecuteReader()
myDataReader2.Read()
result2 = myDataReader2.GetInt32(0)
SQLconn.Close()



I have a table with records:

name rawvalue quality timestamp
s1______-1_____good____12-6-2007 9:45:00
s3______-1_____bad____13-5-2007 11:50:51
s1_____0_____good____14-7-2007 8:40:54
s2_____0____good____15-5-2007 6:00:45
.
.
.
I read the most recent inserted "rawvalue" in the table to initialize 2 asp controls. I get an error for in the second query. And the error is "Invalid attempt to read when no data is present."

I get the same error then I run the query in Sql Server Management Studio.

The problem is with "timestamp". The "Max(timestamp)=14-7-2007 8:40:54"(3rd record) so it diplays he rawvalue="0" for s1.
But for s2 I don't get any values....because the timestamp = 15-5-2007 6:00:45 < 14-7-2007 8:40:54

What modification do I have to do in query to display the ravalues for both s1 and s2?

When I use this:
SELECT [rawvalue] FROM [datastore] WHERE timestamp=((SELECT MAX(timestamp) FROM [datastore]) AND name='s1')

I get incorrect syntax near AND.




-- modified at 13:12 Monday 14th May, 2007
AnswerRe: Problem with query and datareader Pin
Colin Angus Mackay14-May-07 11:18
Colin Angus Mackay14-May-07 11:18 
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 

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.