Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 January 14th, 2007, 09:40 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default syntax error?<%@ Import Namespace="System.Data" %>

hi, could someone please help --------

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="C#" runat="server">
    void Page_Load(Object sender, EventArgs e)
    {
        OleDbConnection objConnection;
        OleDbConnection objCommand;
        string strConnect;
        string strCommand;
        DataSet DataSet1 = new DataSet();

        strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;";

        //If you don't have the grocertogo.mdb database then
        //you will have to change the following three lines

        strConnect += @"Data Source=C:\program files\microsoft.net\FrameworkSDK\";
        strConnect += @"Samples\quickstart\assplus\samples\grocertogo\da ta";
        strConnect += @"\grocertogo.mdb;";

        strConnect += "Persist Security Info=False";

        strCommand = "SELECT ProductName, UnitPrice FROM Products";
        objConnection = new OleDbConnection(strConnect);
        objCommand = new OleDbDataAdapter(strCommand, objConnection);
        objCommand.Fill(DataSet1, "products");
        DataGrid1.DataSource=DataSet1.Tables["Products"].DefaultView;
        DataGrid1.DataBind();

    }
    </script>
    <html>
    <head>
    <title>Data Grid Control example</title>
    </head>
    <body>
    <asp:DataGrid ID="DataGrid1" runat="server" />
    </body>
    </html>


---------------

and i am getting this error:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0029: Cannot implicitly convert type 'System.Data.OleDb.OleDbDataAdapter' to 'System.Data.OleDb.OleDbConnection'

Source Error:



Line 23: strCommand = "SELECT ProductName, UnitPrice FROM Products";
Line 24: objConnection = new OleDbConnection(strConnect);
Line 25: objCommand = new OleDbDataAdapter(strCommand, objConnection);
Line 26: objCommand.Fill(DataSet1, "products");
Line 27: DataGrid1.DataSource=DataSet1.Tables["Products"].DefaultView;


-----------


also, a squigley line is under <%@ Namespace="System.Data" %> - and when hovering over it it says - "syntax error"

any help would be much appreciated,

sincerely

 
Old January 15th, 2007, 02:40 AM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi

 
Old January 16th, 2007, 11:51 AM
Authorized User
 
Join Date: Apr 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you missing page directive first? it seems ok

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance for <xsl:import> and <xsl:include> vikkiefd XSLT 2 April 16th, 2008 08:06 AM
Syntax error? <%@ Import Namespace="System.Data" % fjm9 C# 1 January 16th, 2007 09:17 AM
Help with !> and !< conditional syntax mat41 SQL Language 2 May 31st, 2006 08:13 PM
syntax error on <option selected="selected"> hamid HTML Code Clinic 1 October 13th, 2004 09:20 AM
the book <<Data-Centric.net programing with c#>> jamxx All Other Wrox Books 0 November 18th, 2003 10:56 PM





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