Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2004, 11:39 PM
Authorized User
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cjcd
Default Retrieving value from querystring

I'm trying to display an object from my database, the object in question is specified by a number on the querystring pulled from a prior page, how can I do this?

Here's my code so far, whoch of course gives me an error that follows:

Exception Details: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.

Source Error:


Line 14: Dim objAdapter as new OledbDataAdapter(strSQL, objConnection)
Line 15:
Line 16: objAdapter.Fill(objDataSet, "Noticias")
Line 17:
Line 18: Dim objDataView as New DataView(objDataSet.Tables("Noticias"))

And here's my code:



<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" debug="true" trace="true" %>

<%@ import Namespace="System.Data" %>

<%@ import Namespace="System.Data.Oledb" %>

<script runat="server">



    Sub Page_Load()



        Dim strConnection as String = ConfigurationSettings.AppSettings("myDSN")



        Dim strSQL as String = "SELECT * FROM Noticias WHERE newsID ='" & request.querystring("id") & "'"

        Dim objDataSet as new DataSet()



        Dim objConnection as New OledbConnection(strConnection)

        Dim objAdapter as new OledbDataAdapter(strSQL, objConnection)



        objAdapter.Fill(objDataSet, "Noticias")



        Dim objDataView as New DataView(objDataSet.Tables("Noticias"))



      DataGrid1.DataSource = objDataView

      DataGrid1.DataBind()

    End Sub



</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Armytel - Noticias</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>



<asp:Datalist id="datagrid1" runat="server">

<itemTemplate>

<table width="600" border="1" cellspacing="0" cellpadding="0">

  <tr>

    <td><%# Container.DataItem("txtTitle") %></td>

  </tr>

  <tr>

    <td>Por: | Fuente: (con link) </td>

  </tr>

  <tr>

    <td>Fecha</td>

  </tr>

  <tr>

    <td>&nbsp;</td>

  </tr>

  <tr>

    <td><%# Container.DataItem("txtSummary") %></td>

  </tr>

  <tr>

    <td>&nbsp;</td>

  </tr>

  <tr>

    <td>Noticia con foto alineada a la izquierda. </td>

  </tr>

</table>

</itemTemplate>

</asp:Datalist>

</body>

</html>



 
Old April 29th, 2004, 07:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Is newsID a character value in the database? If not, you have single quotes around the ID: newsID ='" & request.querystring("id") & "'", which need removed.





Similar Threads
Thread Thread Starter Forum Replies Last Post
using querystring melkin Classic ASP Basics 7 April 1st, 2008 09:07 AM
Querystring or not? myself Classic ASP Basics 4 July 4th, 2006 09:01 AM
QueryString Problem mims1979 Beginning PHP 3 January 10th, 2005 08:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.