Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases 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 June 30th, 2004, 11:19 AM
Authorized User
 
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default sql delete statement

hi guys just wondering if this sql statement is correct, im trying to delete records from 2 tables from a database. The user types in the name they wish to delete in the text box and then they hit the button, in the button event code i have the following sql statement,

Dim myselectQuery As String = "DELETE * FROM admin and users where username = '" & TextBox1.Text & "' "

my program is implemented using vb.net and the database is on a sqlserver, many thanks in advance. oh by the way both the admin table and the user table have a primary key as username.

 
Old June 30th, 2004, 01:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

as far as i know, you can't do a delete statment like that.. you have to delete from one table and from the other in 2 diferents sql...

HTH

Gonzalo
 
Old July 7th, 2004, 10:56 PM
Authorized User
 
Join Date: Jul 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DELETE * FROM admin and users where username = '" & TextBox1.Text & "' "

you can only perform a delete statement on one table. also your above code is not correct.
try: DELETE FROM admin and users where username = '" & TextBox1.Text & "' "
notice the asterisk mark is removed.







Similar Threads
Thread Thread Starter Forum Replies Last Post
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
problem with delete statement thas123 SQL Server 2000 6 March 23rd, 2006 01:13 PM
Delete Statement Error Jane SQL Language 1 October 21st, 2005 01:45 PM
T-SQL Delete statement Alcapone C# 3 November 3rd, 2004 01:08 PM
DELETE statement with ASP.NET kaz VS.NET 2002/2003 1 December 9th, 2003 09:35 PM





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