Problem with ADO.NET...

G

Guest

Can someone please tell me why I keep getting the following error???

Input string was not in a correct format.

I keep getting the following error on:

fldTitle.Text = myReader.GetString("header")

I would be really grateful for any advice anyone might have! Thanks



<code>
Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("PageProperties", Myconn)
cmd.CommandType = CommandType.StoredProcedure


Myconn.Open()

Dim objPageID As SqlParameter
objPageID = cmd.Parameters.Add("@pageID", SqlDbType.Int)
objPageID.Direction = ParameterDirection.Input
objPageID.Value = 1 'pageID


Dim myReader As SqlDataReader = cmd.ExecuteReader()
While myReader.Read
fldTitle.Text = myReader.GetString("header")
End While

myReader.Close()
</code>

Store Procedure...

CREATE PROCEDURE dbo.pageProperties
(
@pageID Int
)

AS

SELECT P.pageID, P.creationDate, P.modificationDate, P.description,
P.header, P.content, P.keywords, P.Status, o_OffName
FROM tblOfficePageContent R
INNER JOIN tblOffice O ON
R.officeID = o_OfficeID
INNER JOIN tblPageContent P ON
R.pageID = P.pageID
AND P.pageID = @pageID
GO
 
G

Guest

OK!

But how do I retrieve the values of those columns from my Stored Procedure???

Thanks for the reply!
 
E

Eliyahu Goldin

A result record set generated by your stored procedure is the result of an
regular select statement. Columns are return in the order they are listed in
the select. In your case it will be

fldTitle.Text = myReader.GetString(4)

Eliyahu
 
H

Hans Kesting

Eliyahu said:
A result record set generated by your stored procedure is the result of an
regular select statement. Columns are return in the order they are listed in
the select. In your case it will be

fldTitle.Text = myReader.GetString(4)

Eliyahu

and there is myReader.GetOrdinal("header"), which should
return the "4"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,127
Latest member
CyberDefense
Top