SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old November 18th, 2004, 05:02 AM
vmbs vmbs is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 36 vmbs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 24 sec
Reputation Power: 4
Question drop column in table dsn

i need help for drop colum from table i wrote the below code but it give ERROR:timeout expire

i have one combobox and one button while selecting combox the selected column will drop by clicking the button

i have more than 29 columns in the table vmbs and all columns have an entry in the combobox
it is working with small tables but it will not work with large tables
what can i do plz reply soon

sub command1_click()

dim db as new adodb.connection

dim rs as new adodb.recordset

str=com1.text

db.open "dsn=jay"

set rs=db.excute("select * from vmbs;")

sql="alter table vmbs drop column [" & str & " ];"

db.excute sql

db.close

end sub

Reply With Quote
  #2  
Old November 18th, 2004, 01:13 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 31 m 41 sec
Reputation Power: 180
Why are you opening a recordset first?
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old November 19th, 2004, 11:17 AM
Lauramc's Avatar
Lauramc Lauramc is offline
SQL Slarentice
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2004
Location: In My Happy Place
Posts: 1,783 Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level)Lauramc User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 15 h 47 m 58 sec
Reputation Power: 1095
Talking I think I have an idea for you vmbs...

If I understand your problem correctly, you want to select all of the column names from your vmbs table into a combo box. Then you want to have the user press a button after selecting a column to remove it from that table. The first problem is your select statement. You cannot select column names by saying (SELECT * FROM vmbs) because only the records IN the table will appear. If there are no records, this could be what is causing your timeout.

Therefore, you should create a table called say... "vmbscols". Have an ID column (integer & Primary Key with an identity seed) and a colname column (say varchar(30)). Insert all the CURRENT column names from your vmbs table into this new table. Then on your button_click() event set the record source of your combo box to vmbscols table instead of vmbs. Make sure that the bound column of your combo box (com1) is set to the "colname" column of your new table.

Once you have done that, then you need to execute two SQL commands. The first will delete a ROW from your vmbscols table, the second will alter the vmbs table to remove the column. For example, first you could set your SQL string to "DELETE FROM vmbscols WHERE colname = " & "'" & com1 & "'" &"". Then db.execute SQL.

You could create a second variable, say SQL2 as a string to contain the second SQL statement as in:
Dim SQL2 as String
SQL2 = "ALTER TABLE vmbs DROP COLUMN " & "'" & com1 & "'" &""
db.execute SQL2

Make sure to put all of this in your button click event. Obviously you will have to adapt this a bit to meet your specific needs. If you are using VBA in Access 2000, you should note that you also have to send keys to refresh the tables, otherwise the combo box will not APPEAR to update (even though it does delete the column, it may remain visible in the combo box). I am putting an example of this below (you will want to put this at the END of your button_click() event). I learned this the hard way, as in Access 2000 the "application.RefreshDatabaseWindow" does not work. SendKeys is not the ideal option, but it works.

' This code is necessary to refresh the table.
DoCmd.SelectObject acTable, , True
SendKeys "{F5}", True
DoCmd.SelectObject acForm, "Form1", False

Note that this refreshes the table, then returns you to the form (insert your form name where I put "Form1").

I hope this is helpful for you, please let me know! Also, it would be helpful to know what version of VB you are using so I can better assist you.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > drop column in table dsn


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway