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
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old December 27th, 2006, 02:43 AM
Authorized User
Join Date: Aug 2006
Location: Mumbai, Maharashtra, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to amit_mande@yahoo.com Send a message via AIM to amit_mande@yahoo.com Send a message via MSN to amit_mande@yahoo.com Send a message via Yahoo to amit_mande@yahoo.com
Default Help me in deleting value from database and grid

I am using a datagrid for showing values from database.I have code for showing and deleting records as follows

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Me.IsPostBack = False Then
            Dim myController As New controller("select *from Missing", "Missing")
            Dim ds As DataSet = myController.getdataset()
        End If
    End Sub
    Public Sub bindgrid(ByVal ds As DataSet)
        DataGrid1.DataSource = ds.Tables("Missing")
    End Sub
    Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
        Dim constring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\WebProject\myDb.mdb"
        Dim f, l As String
        f = CType(e.Item.FindControl("FirstName"), TextBox).Text
        l = CType(e.Item.FindControl("LastName"), TextBox).Text
        Dim str As String = "Delete from Missing where (FirstName='" & f & "') and (LastName='" & l & "')"
        Dim con As New OleDbConnection(constring)
        Dim cmd As New OleDbCommand(str, con)
            Dim x As Integer
            x = cmd.ExecuteNonQuery
        Catch ex As Exception
            If Not con Is Nothing Then
            End If
        End Try
        DataGrid1.EditItemIndex = -1
        Dim myController As New controller("select *from Missing", "Missing")
        Dim ds As DataSet = myController.getdataset
        'Label1.Text = myController.exc.Message
    End Sub

It gives me error at bold line.

The error is as follows

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

is there any new way to delete value?
Pls help me.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting multiple rows in data view or grid deepakbachelor SQL Server 2005 1 December 7th, 2007 02:19 PM
deleting entire database x_ray Classic ASP Basics 3 April 4th, 2006 03:02 PM
Deleting Rows in an Editable Data Grid RichardP ASP.NET 1.0 and 1.1 Professional 2 March 1st, 2006 02:19 PM
Deleting data from database jaideepc ADO.NET 0 August 11th, 2004 04:04 AM
Deleting info from Database... jasmine5544 Classic ASP Databases 1 December 2nd, 2003 03:43 PM

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