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

Problems to use my recordset

I'm having issues to use my recordset, this is the error I'm getting:

ResponsablePropuesta.Observaciones
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException:
ResponsablePropuesta.Observaciones

Source Error:
Line 26: 'txtMargen.Text = RSq("ResponsablePropuesta.Margen")
Line 27: 'txtOBS.Text =
Line 28: Response.Write(RSq("ResponsablePropuesta.Observaci ones"))
Line 29:
Line 30: End If
Source File: C:\Documents and Settings\Edgar Salcedo\Mis documentos\Visual
Studio 2005\WebSites\SIP\LineasMod.aspx.vb Line: 28

Stack Trace:
[IndexOutOfRangeException: ResponsablePropuesta.Observaciones]
System.Data.ProviderBase.FieldNameLookup.GetOrdina l(String fieldName) +95
System.Data.SqlClient.SqlDataReader.GetOrdinal(Str ing name) +168
System.Data.SqlClient.SqlDataReader.get_Item(Strin g name) +35
LineasMod.Page_Load(Object sender, EventArgs e) in C:\Documents and
Settings\Edgar Salcedo\Mis documentos\Visual Studio
2005\WebSites\SIP\LineasMod.aspx.vb:28
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3021
And this is my code:

If Not IsPostBack() Then
HiddenField1.Value = Request("id")
cmbRG.SelectedValue = Request("rg")
cmbRP.SelectedValue = Request("rp")
Dim sqlr As String = "SELECT ResponsablePropuesta.Idpropuesta AS
Id, Prospecto.Nombre AS Prospecto, Usuario.IdUsuario AS IdRG, Usuario.Nombre
AS RespGrupo, Usuario_1.IdUsuario AS IdRP, Usuario_1.Nombre AS RespProp,
ResponsablePropuesta.FechaPlanEntrega,
ResponsablePropuesta.ValorPropuestaCOP,
ResponsablePropuesta.ValorPropuestaUSD, ResponsablePropuesta.Margen,
ResponsablePropuesta.Observaciones FROM ResponsablePropuesta INNER JOIN
Propuesta ON ResponsablePropuesta.Idpropuesta = Propuesta.IdPropuesta INNER
JOIN Prospecto ON Propuesta.IdProspecto = Prospecto.IdProspecto INNER JOIN
Usuario ON ResponsablePropuesta.RespGrupo = Usuario.IdUsuario INNER JOIN
Usuario AS Usuario_1 ON ResponsablePropuesta.RespPropuesta =
Usuario_1.IdUsuario WHERE (ResponsablePropuesta.Idpropuesta = " &
Request("id") & ") AND (Usuario.IdUsuario = " & Request("rg") & ") AND
(Usuario_1.IdUsuario = " & Request("rp") & ")"
Dim sqlConn As System.Data.SqlClient.SqlConnection
Dim sqlCmd As System.Data.SqlClient.SqlCommand
Dim strConnection As String
Dim RSq As System.Data.SqlClient.SqlDataReader
strConnection =
ConfigurationManager.ConnectionStrings("SIPconnect ionstring").ConnectionString
'System.Configuration.ConfigurationManager.AppSett ings("Prueba3")
sqlConn = New System.Data.SqlClient.SqlConnection(strConnection)
sqlCmd = New System.Data.SqlClient.SqlCommand(sqlr, sqlConn)
sqlConn.Open()

RSq = sqlCmd.ExecuteReader()
RSq.Read()
'txtFechaPlan.text = RSq("ResponsablePropuesta.FechaPlanEntrega")
'TxtCOP.Text = RSq("ResponsablePropuesta.ValorPropuestaCOP")
'TxtUSD.Text = RSq("ResponsablePropuesta.ValorPropuestaUSD")
'txtMargen.Text = RSq("ResponsablePropuesta.Margen")
'txtOBS.Text =
Response.Write(RSq("ResponsablePropuesta.Observaci ones"))

End If

How can I solve this?

Thx

Nov 15 '08 #1
6 1624
Index out of range means it is asking for a record that does not exist. If I
were guessing, which I am, I would guess the reader found no records. To
avoid this, either make sure there is a record or use a while() and pull all
records off the reader.

Another option is to use a DataSet and confirm there are rows.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
"egsdar" <eg****@discussions.microsoft.comwrote in message
news:9B**********************************@microsof t.com...
I'm having issues to use my recordset, this is the error I'm getting:

ResponsablePropuesta.Observaciones
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException:
ResponsablePropuesta.Observaciones

Source Error:
Line 26: 'txtMargen.Text = RSq("ResponsablePropuesta.Margen")
Line 27: 'txtOBS.Text =
Line 28:
Response.Write(RSq("ResponsablePropuesta.Observaci ones"))
Line 29:
Line 30: End If
Source File: C:\Documents and Settings\Edgar Salcedo\Mis documentos\Visual
Studio 2005\WebSites\SIP\LineasMod.aspx.vb Line: 28

Stack Trace:
[IndexOutOfRangeException: ResponsablePropuesta.Observaciones]
System.Data.ProviderBase.FieldNameLookup.GetOrdina l(String fieldName)
+95
System.Data.SqlClient.SqlDataReader.GetOrdinal(Str ing name) +168
System.Data.SqlClient.SqlDataReader.get_Item(Strin g name) +35
LineasMod.Page_Load(Object sender, EventArgs e) in C:\Documents and
Settings\Edgar Salcedo\Mis documentos\Visual Studio
2005\WebSites\SIP\LineasMod.aspx.vb:28
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3021
And this is my code:

If Not IsPostBack() Then
HiddenField1.Value = Request("id")
cmbRG.SelectedValue = Request("rg")
cmbRP.SelectedValue = Request("rp")
Dim sqlr As String = "SELECT ResponsablePropuesta.Idpropuesta
AS
Id, Prospecto.Nombre AS Prospecto, Usuario.IdUsuario AS IdRG,
Usuario.Nombre
AS RespGrupo, Usuario_1.IdUsuario AS IdRP, Usuario_1.Nombre AS RespProp,
ResponsablePropuesta.FechaPlanEntrega,
ResponsablePropuesta.ValorPropuestaCOP,
ResponsablePropuesta.ValorPropuestaUSD, ResponsablePropuesta.Margen,
ResponsablePropuesta.Observaciones FROM ResponsablePropuesta INNER JOIN
Propuesta ON ResponsablePropuesta.Idpropuesta = Propuesta.IdPropuesta
INNER
JOIN Prospecto ON Propuesta.IdProspecto = Prospecto.IdProspecto INNER JOIN
Usuario ON ResponsablePropuesta.RespGrupo = Usuario.IdUsuario INNER JOIN
Usuario AS Usuario_1 ON ResponsablePropuesta.RespPropuesta =
Usuario_1.IdUsuario WHERE (ResponsablePropuesta.Idpropuesta = " &
Request("id") & ") AND (Usuario.IdUsuario = " & Request("rg") & ") AND
(Usuario_1.IdUsuario = " & Request("rp") & ")"
Dim sqlConn As System.Data.SqlClient.SqlConnection
Dim sqlCmd As System.Data.SqlClient.SqlCommand
Dim strConnection As String
Dim RSq As System.Data.SqlClient.SqlDataReader
strConnection =
ConfigurationManager.ConnectionStrings("SIPconnect ionstring").ConnectionString

'System.Configuration.ConfigurationManager.AppSett ings("Prueba3")
sqlConn = New
System.Data.SqlClient.SqlConnection(strConnection)
sqlCmd = New System.Data.SqlClient.SqlCommand(sqlr, sqlConn)
sqlConn.Open()

RSq = sqlCmd.ExecuteReader()
RSq.Read()
'txtFechaPlan.text =
RSq("ResponsablePropuesta.FechaPlanEntrega")
'TxtCOP.Text = RSq("ResponsablePropuesta.ValorPropuestaCOP")
'TxtUSD.Text = RSq("ResponsablePropuesta.ValorPropuestaUSD")
'txtMargen.Text = RSq("ResponsablePropuesta.Margen")
'txtOBS.Text =
Response.Write(RSq("ResponsablePropuesta.Observaci ones"))

End If

How can I solve this?

Thx
Nov 15 '08 #2
"Gregory A. Beamer" <No************@comcast.netNoSpamMwrote in message
news:us**************@TK2MSFTNGP02.phx.gbl...
>How can I solve this?

Index out of range means it is asking for a record that does not exist. If
I were guessing, which I am, I would guess the reader found no records. To
avoid this, either make sure there is a record or use a while() and pull
all records off the reader.

Another option is to use a DataSet and confirm there are rows.
Or stick with a DataReader and confirm that there are rows:
http://msdn.microsoft.com/en-us/libr...r.hasrows.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 15 '08 #3
"Mark Rae [MVP]" wrote:
"Gregory A. Beamer" <No************@comcast.netNoSpamMwrote in message
news:us**************@TK2MSFTNGP02.phx.gbl...
How can I solve this?
Index out of range means it is asking for a record that does not exist. If
I were guessing, which I am, I would guess the reader found no records. To
avoid this, either make sure there is a record or use a while() and pull
all records off the reader.

Another option is to use a DataSet and confirm there are rows.

Or stick with a DataReader and confirm that there are rows:
http://msdn.microsoft.com/en-us/libr...r.hasrows.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Thanks for your post.
I used rsq.hasrow and actually it has rows, so how can i fix this?

Nov 16 '08 #4
"egsdar" <eg****@discussions.microsoft.comwrote in message
news:BD**********************************@microsof t.com...
>Or stick with a DataReader and confirm that there are rows:
http://msdn.microsoft.com/en-us/libr...r.hasrows.aspx

I used rsq.hasrow and actually it has rows, so how can i fix this?
Do you mean rsq.HasRows()? If so, where do you use that? HasRows() doesn't
appear anywhere in the code you posted...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 16 '08 #5

"Mark Rae [MVP]" wrote:
"egsdar" <eg****@discussions.microsoft.comwrote in message
news:BD**********************************@microsof t.com...
Or stick with a DataReader and confirm that there are rows:
http://msdn.microsoft.com/en-us/libr...r.hasrows.aspx
I used rsq.hasrow and actually it has rows, so how can i fix this?

Do you mean rsq.HasRows()? If so, where do you use that? HasRows() doesn't
appear anywhere in the code you posted...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Well, I did it as part of your suggention just to check.

If rsq.hasrows() then
response.write("With rows")
else
response.write("Without rows")
end if
Nov 16 '08 #6
"egsdar" <eg****@discussions.microsoft.comwrote in message
news:7E**********************************@microsof t.com...
Well, I did it as part of your suggention just to check.

If rsq.hasrows() then
response.write("With rows")
else
response.write("Without rows")
end if

Can you try this, please:

sqlConn.Open()
RSq = sqlCmd.ExecuteReader()
If Rsq.HasRows() Then
RSq.Read()
Response.Write(RSq("Observaciones").ToString())
End If
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 16 '08 #7

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

Similar topics

0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
6
by: Andy | last post by:
Hello, I am having many problems with setting up a parameter query that searches by the criteria entered or returns all records if nothing is entered. I have designed an unbound form with 3...
2
by: Sunil Korah | last post by:
I am having some trouble with opening recordsets. I have used code more or less straight from the access help. But still I am getting some errors. I am unable to work out what exactly I am doing...
9
by: mcbill20 | last post by:
Hello all. I just installed Oracle 10g developer tools on a machine running XP Pro and Office XP. Before this I had just the Oracle 9 client installed. I the previous configuration, I was able to...
3
by: Darryl Gore | last post by:
Hi, My girlfriends mum has just sent me a list of problems with their access database that I set up. firstly they got this error msaccessmp8 has caused an error in MSACCESSMP8.EXE & will...
1
by: Steve Mauldin | last post by:
I have Two ASP.Net applications running on a windows 2000 Server box. One is www.abc.com and one is www.dfg.com . They have the same code in them to connect to the same SQL Server 2000 database...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
4
idsanjeev
by: idsanjeev | last post by:
first i want to use link href to click and display its data on next page. and anther work i want to do selected redio buttons top_id is submetted in another recordset. please help me soon <%@...
6
by: Oko | last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access 2002. One of the reports within the DB uses data that is Dynamic and cannot be stored on the SQL Server. To resolve this, I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.