469,926 Members | 1,767 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

what is wrong?

I was trying to make a simple dataReader....

Sub projets()
Dim conn As New OleDbConnection(connstring)
Dim dr As OleDbDataReader()
Dim cmd As New OleDbCommand()
cmd.CommandText = "select * from projeto order by nome"
cmd.Connection = conn
conn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
End Sub

what is wrong about it?

--
tks.

Daniel Sélen Secches
CWD Web Internet.
www.cwd.com.br
Nov 20 '05 #1
10 2070
Tom
what is wrong about it?


What errors are you getting?
Nov 20 '05 #2
Cor
Hi Daniel,
Sub projets()
Dim conn As New OleDbConnection(connstring)
Dim dr As OleDbDataReader()
Dim cmd As New OleDbCommand()
cmd.CommandText = "select * from projeto order by nome"
cmd.Connection = conn
conn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
End Sub

what is wrong about it?


Is this the end

It can go like this

Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader()
Dim id As String
Dim pr As String
While rdr.Read()
id = rdr.GetInt32(0).ToString
pr = rdr.GetString(1)
End While
rdr.Close()

A little bit stupid like this because the id and pr is all the time
overwritten, but it just a sample.

I hope this helps?

Cor
Nov 20 '05 #3
I'm wondering if you are setting the connection of the
oledbcommand object to a closed connection. Try conn.open
first then set cmd.connection=conn.

-Lee
-----Original Message-----
I was trying to make a simple dataReader....

Sub projets()
Dim conn As New OleDbConnection(connstring)
Dim dr As OleDbDataReader()
Dim cmd As New OleDbCommand()
cmd.CommandText = "select * from projeto order by nome" cmd.Connection = conn
conn.Open()
dr = cmd.ExecuteReader (CommandBehavior.CloseConnection)End Sub

what is wrong about it?

--
tks.

Daniel Sélen Secches
CWD Web Internet.
www.cwd.com.br
.

Nov 20 '05 #4
that error....

Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to
'1-dimensional array of System.Data.OleDb.OleDbDataReader'.
"Tom" <Re**********@here.com> escreveu na mensagem
news:5v********************************@4ax.com...
what is wrong about it?


What errors are you getting?

Nov 20 '05 #5
i've tried it but nothing ... : <

"Lee Moody" <an*******@discussions.microsoft.com> escreveu na mensagem
news:16****************************@phx.gbl...
I'm wondering if you are setting the connection of the
oledbcommand object to a closed connection. Try conn.open
first then set cmd.connection=conn.

-Lee
-----Original Message-----
I was trying to make a simple dataReader....

Sub projets()
Dim conn As New OleDbConnection(connstring)
Dim dr As OleDbDataReader()
Dim cmd As New OleDbCommand()
cmd.CommandText = "select * from projeto order by nome" cmd.Connection = conn
conn.Open()
dr = cmd.ExecuteReader (CommandBehavior.CloseConnection)End Sub

what is wrong about it?

--
tks.

Daniel Sélen Secches
CWD Web Internet.
www.cwd.com.br
.

Nov 20 '05 #6
i'm getting the error on cmd.executeReader(...) the "blue line" appears
under the cmd.executeReader()

Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to
'1-dimensional array of System.Data.OleDb.OleDbDataReader'.
I was just trying to do the exemple that a got from a book.... the exemple
is whit SQL server and i changed it to access DB

here is the book exemple:
=============================================
Dm cn As New SqlConnection("Server=(local)\NetSDK;DataBase=pubs ;Integrated
Security=SSPI")
Dim dr As SqlDataReader
Dim cmd As New SqlCommand()
With cmd
.CommandText = "Select au_lname, au_fname from Authors"
.Connection = cn
End With
cn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim strName As String
While dr.Read
' Add the items to the ListBox1 control
strName = dr("au_lname") & ", " & dr("au_fname")
MessageBox.Show(strName)
End While
cn.Close()
=============================================
tks again

"Cor" <no*@non.com> escreveu na mensagem
news:u1***************@TK2MSFTNGP11.phx.gbl...
Hi Daniel,
Sub projets()
Dim conn As New OleDbConnection(connstring)
Dim dr As OleDbDataReader()
Dim cmd As New OleDbCommand()
cmd.CommandText = "select * from projeto order by nome"
cmd.Connection = conn
conn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
End Sub

what is wrong about it?


Is this the end

It can go like this

Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader()
Dim id As String
Dim pr As String
While rdr.Read()
id = rdr.GetInt32(0).ToString
pr = rdr.GetString(1)
End While
rdr.Close()

A little bit stupid like this because the id and pr is all the time
overwritten, but it just a sample.

I hope this helps?

Cor

Nov 20 '05 #7
Dim dr As OleDbDataReader()

take off the ()

"Daniel Sélen Secches" <danielATcwdDOTcomDOTbr> wrote in message
news:uG****************@tk2msftngp13.phx.gbl...
i'm getting the error on cmd.executeReader(...) the "blue line" appears
under the cmd.executeReader()

Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to
'1-dimensional array of System.Data.OleDb.OleDbDataReader'.
I was just trying to do the exemple that a got from a book.... the exemple
is whit SQL server and i changed it to access DB

here is the book exemple:
=============================================
Dm cn As New SqlConnection("Server=(local)\NetSDK;DataBase=pubs ;Integrated
Security=SSPI")
Dim dr As SqlDataReader
Dim cmd As New SqlCommand()
With cmd
.CommandText = "Select au_lname, au_fname from Authors"
.Connection = cn
End With
cn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim strName As String
While dr.Read
' Add the items to the ListBox1 control
strName = dr("au_lname") & ", " & dr("au_fname")
MessageBox.Show(strName)
End While
cn.Close()
=============================================
tks again

"Cor" <no*@non.com> escreveu na mensagem
news:u1***************@TK2MSFTNGP11.phx.gbl...
Hi Daniel,
Sub projets()
Dim conn As New OleDbConnection(connstring)
Dim dr As OleDbDataReader()
Dim cmd As New OleDbCommand()
cmd.CommandText = "select * from projeto order by nome"
cmd.Connection = conn
conn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
End Sub

what is wrong about it?


Is this the end

It can go like this

Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader()
Dim id As String
Dim pr As String
While rdr.Read()
id = rdr.GetInt32(0).ToString
pr = rdr.GetString(1)
End While
rdr.Close()

A little bit stupid like this because the id and pr is all the time
overwritten, but it just a sample.

I hope this helps?

Cor


Nov 20 '05 #8
On Wed, 25 Feb 2004 15:44:11 -0300, "Daniel Sélen Secches"
<danielATcwdDOTcomDOTbr> wrote:
that error....

Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to
'1-dimensional array of System.Data.OleDb.OleDbDataReader'.

Get rid of the "()"

Nov 20 '05 #9
ohh god,,,, ,that was a stupid error..... i don't belive that

Now it's works....

tks again.....
"CJ Taylor" <no****@blowgoats.com> escreveu na mensagem
news:10*************@corp.supernews.com...
Dim dr As OleDbDataReader()

take off the ()

"Daniel Sélen Secches" <danielATcwdDOTcomDOTbr> wrote in message
news:uG****************@tk2msftngp13.phx.gbl...
i'm getting the error on cmd.executeReader(...) the "blue line" appears
under the cmd.executeReader()

Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to
'1-dimensional array of System.Data.OleDb.OleDbDataReader'.
I was just trying to do the exemple that a got from a book.... the exemple is whit SQL server and i changed it to access DB

here is the book exemple:
=============================================
Dm cn As New SqlConnection("Server=(local)\NetSDK;DataBase=pubs ;Integrated Security=SSPI")
Dim dr As SqlDataReader
Dim cmd As New SqlCommand()
With cmd
.CommandText = "Select au_lname, au_fname from Authors"
.Connection = cn
End With
cn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim strName As String
While dr.Read
' Add the items to the ListBox1 control
strName = dr("au_lname") & ", " & dr("au_fname")
MessageBox.Show(strName)
End While
cn.Close()
=============================================
tks again

"Cor" <no*@non.com> escreveu na mensagem
news:u1***************@TK2MSFTNGP11.phx.gbl...
Hi Daniel,

> Sub projets()
> Dim conn As New OleDbConnection(connstring)
> Dim dr As OleDbDataReader()
> Dim cmd As New OleDbCommand()
> cmd.CommandText = "select * from projeto order by nome"
> cmd.Connection = conn
> conn.Open()
> dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> End Sub
>
> what is wrong about it?

Is this the end

It can go like this

Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader()
Dim id As String
Dim pr As String
While rdr.Read()
id = rdr.GetInt32(0).ToString
pr = rdr.GetString(1)
End While
rdr.Close()

A little bit stupid like this because the id and pr is all the time
overwritten, but it just a sample.

I hope this helps?

Cor



Nov 20 '05 #10
ohh god,,,, ,that was a stupid error..... i don't belive that

Now it's works....

tks again.....

"_Andy_" <wi******@nospamthanks.gov> escreveu na mensagem
news:rd********************************@4ax.com...
On Wed, 25 Feb 2004 15:44:11 -0300, "Daniel Sélen Secches"
<danielATcwdDOTcomDOTbr> wrote:
that error....

Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to
'1-dimensional array of System.Data.OleDb.OleDbDataReader'.

Get rid of the "()"

Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

72 posts views Thread by E. Robert Tisdale | last post: by
121 posts views Thread by typingcat | last post: by
28 posts views Thread by Madhur | last post: by
46 posts views Thread by Keith K | last post: by
13 posts views Thread by Jason Huang | last post: by
9 posts views Thread by Pyenos | last post: by
3 posts views Thread by Siong.Ong | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.