Can somebody pllease tell me what is the error on this code. I got the error
on the executereader line.
Public Function verificarcedula(ByVal cedula As String) As Boolean
Dim mycmd As SqlCommand = New SqlCommand("select * from maestro where
cod_empl=@dotnet.itags.org.cedula", SqlConnection1)
mycmd.Parameters.Add("@dotnet.itags.org.cedula", cedula)
Dim myreader As SqlDataReader
Try
SqlConnection1.Open()
myreader = mycmd.ExecuteReader
If (myreader.Read) Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw ex
Finally
myreader.Close()
SqlConnection1.Close()
End Try
End Function
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEVWhich line ?
You have an object that is not created (ie. Nothing).
"Luis Esteban Valencia" <luisvalen@.haceb.com> a crit dans le message de
news:eECvzGZxEHA.1988@.TK2MSFTNGP12.phx.gbl...
> Can somebody pllease tell me what is the error on this code. I got the
error
> on the executereader line.
> Public Function verificarcedula(ByVal cedula As String) As Boolean
> Dim mycmd As SqlCommand = New SqlCommand("select * from maestro where
> cod_empl=@.cedula", SqlConnection1)
> mycmd.Parameters.Add("@.cedula", cedula)
> Dim myreader As SqlDataReader
> Try
> SqlConnection1.Open()
> myreader = mycmd.ExecuteReader
> If (myreader.Read) Then
> Return True
> Else
> Return False
> End If
> Catch ex As Exception
> Throw ex
> Finally
> myreader.Close()
> SqlConnection1.Close()
> End Try
> End Function
>
> --
> LUIS ESTEBAN VALENCIA
> MICROSOFT DCE 2.
> MIEMBRO ACTIVO DE ALIANZADEV
>
This line.
myreader = mycmd.ExecuteReader
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
"Patrice" <nobody@.nowhere.com> escribi en el mensaje
news:uS2ArOZxEHA.3096@.TK2MSFTNGP14.phx.gbl...
> Which line ?
> You have an object that is not created (ie. Nothing).
> --
> "Luis Esteban Valencia" <luisvalen@.haceb.com> a crit dans le message de
> news:eECvzGZxEHA.1988@.TK2MSFTNGP12.phx.gbl...
> error
>
Try creating the dataReader object with the new keyword
Dim myreader As New SqlDataReader
+++++++++++++++++++++++++++++++
"Luis Esteban Valencia" wrote:
> Can somebody pllease tell me what is the error on this code. I got the err
or
> on the executereader line.
> Public Function verificarcedula(ByVal cedula As String) As Boolean
> Dim mycmd As SqlCommand = New SqlCommand("select * from maestro where
> cod_empl=@.cedula", SqlConnection1)
> mycmd.Parameters.Add("@.cedula", cedula)
> Dim myreader As SqlDataReader
> Try
> SqlConnection1.Open()
> myreader = mycmd.ExecuteReader
> If (myreader.Read) Then
> Return True
> Else
> Return False
> End If
> Catch ex As Exception
> Throw ex
> Finally
> myreader.Close()
> SqlConnection1.Close()
> End Try
> End Function
>
> --
> LUIS ESTEBAN VALENCIA
> MICROSOFT DCE 2.
> MIEMBRO ACTIVO DE ALIANZADEV
>
>
Well, the reader object reference is only being assigned to in this
line of code, so it should not be a problem (and the ExecuteReader
method will take care of creating the object in any case). If anything
it is the SqlCommand object that we need to be suspicious of, but it
looks as if it was New'ed appropriately.
Have you stepped through the code with the debugger Luis?
Scott
http://www.OdeToCode.com/blogs/scott/
On Mon, 8 Nov 2004 09:39:02 -0800, "Tampa .NET Koder"
<TampaNETKoder@.discussions.microsoft.com> wrote:
>Try creating the dataReader object with the new keyword
>Dim myreader As New SqlDataReader
>+++++++++++++++++++++++++++++++
>
>"Luis Esteban Valencia" wrote:
>
Did you checked they are not Nothing ? I would check also SqlConnection1.
Patrice
"Luis Esteban Valencia" <luisvalen@.haceb.com> a crit dans le message de
news:e1qoHUZxEHA.2600@.TK2MSFTNGP09.phx.gbl...
> This line.
> myreader = mycmd.ExecuteReader
>
> --
> LUIS ESTEBAN VALENCIA
> MICROSOFT DCE 2.
> MIEMBRO ACTIVO DE ALIANZADEV
> "Patrice" <nobody@.nowhere.com> escribi en el mensaje
> news:uS2ArOZxEHA.3096@.TK2MSFTNGP14.phx.gbl...
>
0 comments:
Post a Comment