Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 30th, 2004, 11:19 AM
Authorized User
Join Date: Jun 2004
Location: , , .
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.

Reply With Quote
  #2 (permalink)  
Old June 30th, 2004, 01:43 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

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...


Reply With Quote
  #3 (permalink)  
Old July 7th, 2004, 10:56 PM
Authorized User
Join Date: Jul 2004
Location: , , Philippines.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

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.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 11:27 PM.

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