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. 6 4710
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.
.
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.
.
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!
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!
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!
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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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"...
|
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...
|
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 =...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |