hi i´m new developing on asp.net, im trying to get some data from my database and paste it on a page using a table, i do it early whit different data and my metod works, but with this specific data my metod doesn´t work, my data types on the other pages
are everything string, but this time i have some string and a new one int, i don't know if this affect my metod or what
http://imageshack.us/photo/my-images/198/sinttulocpm.jpg/ loos like is 0, but if i make the same query directly on my server the query returns something different
you don´t see it 'cause, it doesn't appear, the function doesn't get it from the database, that is my problem ... the value of resultado[6] exist in the database, but i don't know why i can't get it in my function, i'm doing something wrong, 'cause the string
data, i can get it; but the integer value, i can't get it
i can't 'cause it jumps to the exception even if put a watch point in the line of resultado[6], and in the line after and before, the program get to resultado[6], and next jump to the exception
ahinestrosa1...
Member
61 Points
51 Posts
problem bringing data from mi db to the web page
Mar 02, 2012 06:44 PM|LINK
hi i´m new developing on asp.net, im trying to get some data from my database and paste it on a page using a table, i do it early whit different data and my metod works, but with this specific data my metod doesn´t work, my data types on the other pages are everything string, but this time i have some string and a new one int, i don't know if this affect my metod or what
http://imageshack.us/photo/my-images/834/sinttuloflz.jpg/
http://imageshack.us/photo/my-images/17/sinttulo2ob.jpg/
in my pictures, when i'm debugin the fuction jump from
misDatos.codListaPrecios = resultado.GetString(5);
misDatos.precio = resultado.GetInt32(6);
to
catch (Exception ex)
{
i need this lines 'cause is where my data is retourned and pasted on the table
misDatos.precio = resultado.GetInt32(6);
precioProducto.Add(misDatos);
table code(view): <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Resultado consulta de puntos de entrega: </h2> <table> <tr> <th>Tipo Articulo</th> <th>Clave #1</th> <th>Clave #2</th> <th>lista de Precios</th> <th>precio</th> </tr> <% foreach (var item in Model) { %> <tr> <td> <%=Html.Encode(item.tipoArticulo)%> </td> <td> <%=Html.Encode(item.clave1)%> </td> <td> <%=Html.Encode(item.clave2)%> </td> <td> <%=Html.Encode(item.codListaPrecios)%> </td> <td> <%=Html.Encode(item.precio)%> </td> </tr> <% } %> </table> <%= Html.ActionLink("Consulta Precios", "ConsultaPrecios") %> </asp:Content> controller: public ActionResult listarPrecios(string tipArt, string clave1, string clave2, string listPrec ){ if (tipArt == "A" || tipArt == "B" || tipArt == "L") { List<Pedidos> misDatos = miConexion.ConsultaPreciosA(username, password, tipArt, clave1, clave2, listPrec); return View(misDatos); } else { if (tipArt == "N" || tipArt == "H"){ List<Pedidos> misDatos = miConexion.ConsultaPreciosB(username, password, tipArt, clave1, listPrec); return View(misDatos); }else{ ModelState.AddModelError("", "Es necesario seleccionar el tipo de articulo"); return View(); } } connection metod: public List<Pedidos> ConsultaPreciosA(string username, string password, string words, string clave1, string clave2, string lista) { List<Pedidos> precioProducto = new List<Pedidos>(); try { OleDbConnection conexion = new OleDbConnection (@"connection data ...."); OleDbCommand comandoSelect = new OleDbCommand(@" sql sentence ....')", conexion); comandoSelect.Connection = conexion; conexion.Open(); comandoSelect.ExecuteNonQuery(); OleDbDataReader resultado = comandoSelect.ExecuteReader(); while (resultado.Read()) { Pedidos misDatos = new Pedidos(); misDatos.tipoArticulo = resultado.GetString(0); misDatos.clave1 = resultado.GetString(1); misDatos.clave2 = resultado.GetString(2); misDatos.codListaPrecios = resultado.GetString(5); misDatos.precio = resultado.GetInt32(6); precioProducto.Add(misDatos); } conexion.Close(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } return precioProducto; }JohnLocke
Contributor
3014 Points
689 Posts
Re: problem bringing data from mi db to the web page
Mar 02, 2012 07:39 PM|LINK
Can you post the error message from the exception?
ahinestrosa1...
Member
61 Points
51 Posts
Re: problem bringing data from mi db to the web page
Mar 02, 2012 07:45 PM|LINK
this?
http://imageshack.us/photo/my-images/843/sinttulofh.jpg/
JohnLocke
Contributor
3014 Points
689 Posts
Re: problem bringing data from mi db to the web page
Mar 02, 2012 07:49 PM|LINK
I'm not sure. It's too small to read. Copy and paste the error.
ignatandrei
All-Star
134521 Points
21576 Posts
Moderator
MVP
Re: problem bringing data from mi db to the web page
Mar 02, 2012 07:53 PM|LINK
put a breakpoint on( or right before)
misDatos.precio = resultado.GetInt32(6);
and tell us the value of
resultado[6]
ahinestrosa1...
Member
61 Points
51 Posts
Re: problem bringing data from mi db to the web page
Mar 02, 2012 08:04 PM|LINK
http://imageshack.us/photo/my-images/198/sinttulocpm.jpg/ loos like is 0, but if i make the same query directly on my server the query returns something different
http://imageshack.us/photo/my-images/688/sinttulopof.jpg/
edit:
if i remove
misDatos.precio = resultado.GetInt32(6);
the function works perfectly fine, so the problem is this?? how i handle that data?
i´m taking th rigth data, butt that specific data is an integer var
ignatandrei
All-Star
134521 Points
21576 Posts
Moderator
MVP
Re: problem bringing data from mi db to the web page
Mar 03, 2012 04:32 AM|LINK
I do not see in your images
resultado[6]
What is the value?!(Maybe it is null in the database!)
ahinestrosa1...
Member
61 Points
51 Posts
Re: problem bringing data from mi db to the web page
Mar 05, 2012 11:51 AM|LINK
you don´t see it 'cause, it doesn't appear, the function doesn't get it from the database, that is my problem ... the value of resultado[6] exist in the database, but i don't know why i can't get it in my function, i'm doing something wrong, 'cause the string data, i can get it; but the integer value, i can't get it
ignatandrei
All-Star
134521 Points
21576 Posts
Moderator
MVP
Re: problem bringing data from mi db to the web page
Mar 05, 2012 12:19 PM|LINK
again , put into the watch BEFORE assigning.
ahinestrosa1...
Member
61 Points
51 Posts
Re: problem bringing data from mi db to the web page
Mar 05, 2012 12:28 PM|LINK
i can't 'cause it jumps to the exception even if put a watch point in the line of resultado[6], and in the line after and before, the program get to resultado[6], and next jump to the exception