473,320 Members | 2,088 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,320 software developers and data experts.

datareader.getstring(0) error

Hi,
my code is very simple.

dim cm as oledbcommand= new oledbcommand("select * from page " ,cn)
cn.open()
Dim dr As OleDbDataReader = cm.ExecuteReader()
dim cate=dr.getstring(1) 'error line"
label1.text=cate

but there is error for dr.getstring(1), the error reads:the data of this
column does not exist:
I am sure the second line exist(not null) and is string type.

when add a read() before the error line,then there is no error. And in
another sub, I can output the same datareader content using a do while
read() function.

Can anyone give me a hint?

Nakhi
From Lijinag,China.
Nov 17 '05 #1
6 4708
Hi
Try with the following code:

RULE: Always call Read before accessing data.

myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read()) {
Console.WriteLine(myReader.GetInt32(0) + ", " +
myReader.GetString(1));
}
HTH
Ravikanth
-----Original Message-----
Hi,
my code is very simple.

dim cm as oledbcommand= new oledbcommand("select * from page " ,cn) cn.open()
Dim dr As OleDbDataReader = cm.ExecuteReader()
dim cate=dr.getstring(1) 'error line"
label1.text=cate

but there is error for dr.getstring(1), the error reads:the data of thiscolumn does not exist:
I am sure the second line exist(not null) and is string type.
when add a read() before the error line,then there is no error. And inanother sub, I can output the same datareader content using a do whileread() function.

Can anyone give me a hint?

Nakhi
From Lijinag,China.
.

Nov 17 '05 #2
Hi
Try with the following code:

RULE: Always call Read before accessing data.

myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read()) {
Console.WriteLine(myReader.GetInt32(0) + ", " +
myReader.GetString(1));
}
HTH
Ravikanth
-----Original Message-----
Hi,
my code is very simple.

dim cm as oledbcommand= new oledbcommand("select * from page " ,cn) cn.open()
Dim dr As OleDbDataReader = cm.ExecuteReader()
dim cate=dr.getstring(1) 'error line"
label1.text=cate

but there is error for dr.getstring(1), the error reads:the data of thiscolumn does not exist:
I am sure the second line exist(not null) and is string type.
when add a read() before the error line,then there is no error. And inanother sub, I can output the same datareader content using a do whileread() function.

Can anyone give me a hint?

Nakhi
From Lijinag,China.
.

Nov 17 '05 #3
Hi,

you must use Read() in order to populate the reader.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
Hi,

you must use Read() in order to populate the reader.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5
thanx,it works, that is move the cursor to the first line.

Nakhi
Lijiang,Yunnan,China,Asia.
"Natty Gur" <na***@dao2com.com> дÈëÏûÏ¢ÐÂÎÅ
:Ov**************@tk2msftngp13.phx.gbl...
Hi,

you must use Read() in order to populate the reader.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #6
thanx,it works, that is move the cursor to the first line.

Nakhi
Lijiang,Yunnan,China,Asia.
"Natty Gur" <na***@dao2com.com> дÈëÏûÏ¢ÐÂÎÅ
:Ov**************@tk2msftngp13.phx.gbl...
Hi,

you must use Read() in order to populate the reader.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #7

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

Similar topics

0
by: Mike | last post by:
I am trying to use a datareader to retrieve data and set some properties. I am getting a "Specified method is not supported" error on Line xxx. The data base is Oracle 9i and the field is a...
0
by: Nakhi | last post by:
Hi, my code is very simple. dim cm as oledbcommand= new oledbcommand("select * from page " ,cn) cn.open() Dim dr As OleDbDataReader = cm.ExecuteReader() dim cate=dr.getstring(1) 'error line"...
0
by: Nakhi | last post by:
Hi, I want to display a single record datareader and get a value from it. But I can't do both together. After "dim dr as Oledbdatareader=cmCat.ExecuteReader()", the following is OK(display this...
5
by: Catalin Porancea | last post by:
Whenever I try this: ____________________________________________________________________ Dim cmd_sp_payments As SqlCommand = New SqlCommand("sp_payments", con) cmd_sp_payments.CommandType =...
2
by: Lee Walters | last post by:
Hi All I'm doing a 'select * from table' in my DataReader below and populating an array with the results. Obvisouly I'm only getting the first field from the results by the use of the...
3
by: Agnes | last post by:
i will select over 30 fieldsname from myTable. If i use datareader, my way to get the result is (loop - the datareader) and strResult = myReader.getstring(12) . Can I use the itemname to get the...
2
by: Goran | last post by:
I'm a student and I've just started to learn Visual Studio.NET. I have a project to make a web application. I have a problem to connect to the database and retriving the PassType of the...
1
by: nasirmajor | last post by:
Dear All, im fetching record from database using datareader, and is displaying them in the textboxes. when user change the text fields and then presses the update button the record should be...
1
by: Cerebrus | last post by:
Hi all, Using : .NET 1.1, SQL Server 2000, Win 2K. Could anyone confirm if there is a bug in the SqlDataReader.GetChars() method when using CommandBehavior.SequentialAccess to get a BLOB...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.