Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.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 6th, 2006, 06:23 AM
Authorized User
Join Date: Jan 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default delete is not working

System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '*'. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
This is the error generated in the del.aspx page.
from the webform1.apsx page there is a delete hyperlink which goes to
del.aspx file ie the below file and sqlComm.ExecuteNonQuery()is generating the above error message.there is no problem with the sql statement.i printed it out.its passing the data properly.ie
DELETE * FROM teachers where TID ='1010'

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="vb" runat="server">
Sub Page_Load
dim cv as string
dim str as string
Dim strConnection As String = "user id=sa;password=admin;server=.;initial catalog=students"
Dim cn As SqlConnection = New SqlConnection(strConnection)
Dim strSelect As String = "DELETE * FROM teachers where TID ='"& str &"' "
Dim sqlComm As new SqlCommand(strSelect,cn)
catch ex as exception
end try
end sub


<form name="form1" method="post" action="table1.aspx">

Old January 6th, 2006, 09:41 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Your SQL command is incorrect, you don't need a field list or even the FROM:

Dim strSelect As String = "DELETE teachers where TID ='"& str &"' "


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to delete file System.IO.Delete error maricar C# 13 March 14th, 2014 06:50 AM
Delete Button not working in Wrox CMS VB Sojan80 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 June 16th, 2007 03:23 AM
Delete query not working Mitch PHP Databases 4 January 4th, 2006 08:00 AM
Delete Query not working kbonney98 Access 1 April 14th, 2005 06:29 AM
Edit/Delete ButtonColumn not working planoie ASP.NET 1.0 and 1.1 Professional 9 August 30th, 2004 07:39 AM

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