473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

get values from query

i have a simple query
SELECT User_Pass,id FROM Users
and i want using ExecuteReader to get the values of this 2 columns into
parameters.
when i try to do :
Dim reader As SqlDataReader = myCommand.ExecuteReader()
and then
reader.GetString(0) i get :
Invalid attempt to read when no data is present
while for suer i know that there is a data
what to do?
thnaks in advane
peleg

Jul 8 '07 #1
2 1228
"pelegk1" <pe*****@discussions.microsoft.comwrote in message
news:F8**********************************@microsof t.com...
>i have a simple query
SELECT User_Pass,id FROM Users
and i want using ExecuteReader to get the values of this 2 columns into
parameters.
when i try to do :
Dim reader As SqlDataReader = myCommand.ExecuteReader()
and then
reader.GetString(0) i get :
Invalid attempt to read when no data is present
while for suer i know that there is a data
what to do?

You've forgotten to call the Read method on the SqlDataReader:
http://msdn2.microsoft.com/en-us/lib...ader.read.aspx

Dim reader As SqlDataReader = myCommand.ExecuteReader()
reader.Read()
reader.GetString(0)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 8 '07 #2
On 8 Jul, 22:04, pelegk1 <pele...@discussions.microsoft.comwrote:
i have a simple query
SELECT User_Pass,id FROM Users
and i want using ExecuteReader to get the values of this 2 columns into
parameters.
when i try to do :
Dim reader As SqlDataReader = myCommand.ExecuteReader()
and then
reader.GetString(0) i get :
Invalid attempt to read when no data is present
while for suer i know that there is a data
what to do?
thnaks in advane
peleg
You must execute the statement

reader.Read

before attempting to access the results with GetString etc. The
ExecuteReader method only creates a reader object, it doesn't retrieve
any data.

HTH

Jul 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wilder | last post by:
I'm trying to update a field in one table with the minimum values of the field in another table. The two tables are linked via a common field. I want to populate a date field in one table with...
3
by: MX1 | last post by:
I'm ready to pull the hair out of my head. I have a query with a couple of parameters that I want to get from combo boxes on a form. One parameter is a date with a dynamically calculated year and...
2
by: Todd D. Levy | last post by:
I have a table of Country names & Country codes in alphabetical order. This is a lookup table that a number of other tables use to populate the Country field via a drop down Combo Box on the...
3
by: JOEP | last post by:
What do I need to do to allow an append query to post null values to records in a field of the destination table? Basically I want to allow records with null values to post to the table. The append...
19
by: bdt513 | last post by:
I am trying to extract the values from a query using VBA. Specifically, I want to concatenate all the values of the "rosEmail" field from query "qselRosterEmailList" into one string (strEmails). I...
2
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
3
by: robboll | last post by:
I am building an ASP.NET data entry form and when I change the values per the dropdowns and click "save", the old values remain. Are there any suggestions on how to update the variables to the...
4
by: Juan Jose Costello Levien | last post by:
Hello, I am writing my first trigger in C for PostgreSQL. It compiles Ok, and added it to the database using CREATE TRIGGER. But when I try to fire it, psql simply says 'The connection was lost"....
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
7
by: sparks | last post by:
I am working on a database that has a lot of calculated values on the forms. These were never put into the tables. But were tied to unbound fields on the forms. Now 8000 records later they want...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.