A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Alter Query giving an error
Joined: Oct 02, 2003
Sep 22, 2005 00:49:00
alterQuery(String ColumnName) throws
= "Added a Column Successfully";
stmt.executeUpdate("alter table Machine_Details add '"+ColumnName+"' varchar(10)");
this is being accessed in my jsp like
String message = myclass.alterQuery(request.getParameter("namecolumn"));
where namecolumn is the textbox name.
this is giving an error ..
: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'Machine_length'.
here machine _length is the value given in the text box...
Joined: Jul 20, 2005
Sep 22, 2005 02:30:00
Do you know the actual SQL that is being issued?
Joined: Apr 14, 2004
Sep 22, 2005 02:33:00
Double check the alter table syntax for SQL Server (
). You don't put quotes round new columns.
As an aside, I'm guessing you have your reasons, but its not usually a good idea to allow DDL statements from a Web App.
[ September 22, 2005: Message edited by: Paul Sturrock ]
Maximilian Xavier Stocker
Joined: Sep 20, 2005
Sep 22, 2005 09:10:00
I believe the syntax should be
Because you could be adding an index too. I am not sure about the quotes around the name either but at least try specifiying that you are in fact adding a COLUMN.
I agree. Here's the link:
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Alter Query giving an error
Sql query ignores variable
Another Question about datetime
Create procedure for inserting record into table : Table name dynamically as an Param
simple Update fail
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013