Alter Table

M

MDB

I just upgraded my mobile DBs to 3.0 and CF 2.0 and am now having problems
altering tables. If I run the sql form Query Analyzer 3.0 or from Microsoft
SQL Server Management Studio the sqls run fine however, if I run it from
within my application it never alters the table and always returns -1 with
no error. Below is how I am running it in my code, anyone have any ideas
why it isn't working?


SqlCeCommand dc = new SqlCeCommand(sql, conn, trans);
intResult = dc.ExecuteNonQuery();
dc.Dispose();

sql = ALTER TABLE company ADD COLUMN base_latitude nvarchar(20);


TIA
 
G

Ginny Caughey MVP

You do have quotes around the SQL string, right?

Ginny

MDB said:
I just upgraded my mobile DBs to 3.0 and CF 2.0 and am now having problems
altering tables. If I run the sql form Query Analyzer 3.0 or from
Microsoft
SQL Server Management Studio the sqls run fine however, if I run it from
within my application it never alters the table and always returns -1 with
no error. Below is how I am running it in my code, anyone have any ideas
why it isn't working?


SqlCeCommand dc = new SqlCeCommand(sql, conn, trans);
intResult = dc.ExecuteNonQuery();
dc.Dispose();

sql = ALTER TABLE company ADD COLUMN base_latitude nvarchar(20);


TIA

--

Ginny Caughey
Device Application Development MVP

www.wasteworks.com
Software for Waste Management
 
G

Ginny Caughey MVP

I don't know why this should fail for you. Do you only have the problem with
upgraded databases? I didn't have any problem with similar code using a new
database, although intResult returns -1 even when the new column is added.

Ginny

MDB said:

--

Ginny Caughey
Device Application Development MVP

www.wasteworks.com
Software for Waste Management
 
M

MDB

The results didn't use to return -1 on a alter table , since it is now
returning -1 even though it was sucessful, I was rolling back the
transaction which is way it was appearing not to run. I just changed my
function to return 1 if it is an alter or create. Thanks
 
G

Ginny Caughey MVP

I'm glad you've got it working. Thanks for reporting back.

Ginny

MDB said:
The results didn't use to return -1 on a alter table , since it is now
returning -1 even though it was sucessful, I was rolling back the
transaction which is way it was appearing not to run. I just changed my
function to return 1 if it is an alter or create. Thanks

--

Ginny Caughey
Device Application Development MVP

www.wasteworks.com
Software for Waste Management
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top