Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 7th, 2005, 03:38 AM
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to NitinJoshi
Default Ado.net Problem...

<%@ Import Namespace="System.Data.OleDb" %>
    <script runat="server">
    sub Add(Source As Object, e As EventArgs)
    dim sql as string
    sql="insert into info values(@n,@a,@t,@e)"
    dim insCom as new OleDbCommand(sql,OleDbConnection1)
    OleDbDataAdapter1.InsertCommand=InsCom
    OleDbDataAdapter1.Insercommand.Parameters.Add(new OleDbParameter("@n",oledbType.Char,30))
    OleDbDataAdapter1.Insercommand.Parameters("@n").Va lue=TextBox1.text
    OleDbConnection1.open()
    OleDbDataAdapter1.InsertCommand.ExecuteNonQuery()
    OleDbConnection1.Close()
    end sub
    </script>

This is the code which is giving me an error like..
----------------------------------------------------------

Compiler Error Message: BC30451: Name 'OleDbConnection1' is not declared.
http://localhost/Web_dev/Databse_Conne/Info_Add.aspx(7) : error BC30451: Name 'OleDbConnection1' is not declared.

    dim Com as new OleDbCommand(sql,OleDbConnection1)
                                    ~~~~~~~~~~~~~~~~
http://localhost/Web_dev/Databse_Conne/Info_Add.aspx(8) : error BC30451: Name 'OleDbDataAdapter1' is not declared.

    OleDbDataAdapter1.InsertCommand=Com
    ~~~~~~~~~~~~~~~~~
http://localhost/Web_dev/Databse_Conne/Info_Add.aspx(9) : error BC30451: Name 'OleDbDataAdapter1' is not declared.

    OleDbDataAdapter1.Insercommand.Parameters.Add(new OleDbParameter("@n",oledbType.Char,30))
    ~~~~~~~~~~~~~~~~~
http://localhost/Web_dev/Databse_Conne/Info_Add.aspx(10) : error BC30451: Name 'OleDbDataAdapter1' is not declared.

    OleDbDataAdapter1.Insercommand.Parameters("@n").Va lue=TextBox1.text
    ~~~~~~~~~~~~~~~~~
http://localhost/Web_dev/Databse_Conne/Info_Add.aspx(11) : error BC30451: Name 'OleDbConnection1' is not declared.

    OleDbConnection1.open()
    ~~~~~~~~~~~~~~~~
http://localhost/Web_dev/Databse_Conne/Info_Add.aspx(12) : error BC30451: Name 'OleDbDataAdapter1' is not declared.

    OleDbDataAdapter1.InsertCommand.ExecuteNonQuery()
    ~~~~~~~~~~~~~~~~~
http://localhost/Web_dev/Databse_Conne/Info_Add.aspx(13) : error BC30451: Name 'OleDbConnection1' is not declared.

    OleDbConnection1.Close()
     ~~~~~~~~~~~~~~~~~

Any ANswres Pls...

Thanx!!
 
Old January 7th, 2005, 05:07 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

I just had a rough look at the code and ...

1. OleDbDataAdapter OleDbDataAdapter1 = new OleDbDataAdapter(); -- is missing. Similarly connection object is also missing.
2. Couple of places it has been written as OleDbDataAdapter1.Insercommand ---> it should be OleDbDataAdapter1.InsertCommand

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old January 10th, 2005, 04:49 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

also declare 'OleDbConnection1' & 'OleDbDataAdapter1' in this scope or in the class scope.



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa





Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO.Net Problem akhilesh_g ASP.NET 2.0 Professional 2 December 18th, 2007 05:33 AM
how to deal with this problem related with ADO.NET zouky ADO.NET 2 October 8th, 2004 04:30 AM
'like' problem with asp.net/ ado badgolfer Access ASP 2 September 16th, 2004 01:50 PM
ADO.NET Problem lakmaldp ADO.NET 1 July 15th, 2004 01:58 AM
ADO.NET Problem dfb78 Classic ASP Databases 1 June 5th, 2003 05:01 PM





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