Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 337105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:18:17+00:00 2026-05-12T10:18:17+00:00

So I’m running Extjs on top of Rails 2.3.3 against a SQL Server DB.

  • 0

So I’m running Extjs on top of Rails 2.3.3 against a SQL Server DB. I’m able to pull data from the DB and display it, but I’m unable to create, update or destroy.

Oddly enough, it’s not throwing console or any other errors on attempted updates or deletes — it simply fails.

On create, an InvalidStatement error gets thrown, probably related to the fact that new rows aren’t being assigned an appropriate ID. They’re getting assigned a null ID, and of course it’s not allowed as an identity value.

Has anybody encountered anything similar? Any ideas on workarounds for the issues on create, update or destroy using Extjs + SqlServer?

Thanks!

UPDATE:

Auto-increment is set on the ID field of the table in question. The specific error I’m getting handed back:

 ActiveRecord::StatementInvalid (DVI::DatabaseError: 37000 (339) [ODBC SQL Server Driver][SQL Server] DEFAULT or NULL are not allowed as explicit identity values. INSERT INTO [table] ([username], [fullname], [ID], [password], [superuser]) VALUES('testing', 'testing', NULL, 'testing', 1)):
 # ... ruby exceptions mostly springing from the sqlserver adapter ...

Note that if I pop open the debugger and add in the ID manually, it works fine…

UPDATE2:

On update/destroy, the initial POST request gets constructed with the proper (modified) field data, and a successful response is shown. However, the update data is not reflected in the subsequent GET request.

Digging into to the logs, we find the SQL generated on update has the following issue:

 Administrators Load (0.0ms)   SELECT * FROM [Administrators] WHERE ([Administrators].[id] = '2')
 EXECUTE (0.0ms)   BEGIN TRANSACTION
 Administrators Update (0.0ms)   UPDATE [Administrators] SET [superuser] = 1 WHERE [id] = NULL

A similar issue is plaguing the destroy requests.

What’s going on here? How/why is the id getting set to null in between pulling the appropriate record and performing the operation?

Note that this is the behavior even when I manually perform this operation in the debugger, i.e.,

(rdb:63) Administratiors.find(2).destroy

selects the appropriate row based on ID, but then attempts to delete the row from the table whose id is NULL. Which of course fails…

UPDATE3:

OK, so the only way I’ve found to get the delete operation to work is to roll my own SQL. Replacing @admin.destroy with

sql = ActiveRecord::Base.connection()
sql.begin_db_transaction
sql.execute("SELECT * FROM Administrators WHERE ([Administrators].[id] = #{params[:id]})");
sql.delete("DELETE FROM Administrators WHERE ([Administrators].[id] = #{params[:id]})");
sql.commit_db_transaction

performs the operation as expected.

UPDATE4:

This also works:

Administrators.delete(params[:id])

UPDATE5:

Alright, so now CRUD works between Extjs and SQL server. But it’s an ugly hack (the update operation especially) and I’d love some insight on how to do this more cleanly:

# POST /administrators
def create
  @administrator = Administrators.new(params[:administrators])
  @administrator.ID = Administrators.all.length+1

  respond_to do |format|
    format.html
    format.ext_json {render :json => @administrator.to_ext_json(:success => @administrator.save!)}
  end
end

# PUT /administrators/1
def update
  attrs_to_update = ""
  params[:administrators].each {|k,v| attrs_to_update += "#{k} = \'#{v}\', "}
  attrs_to_update = attrs_to_update.strip.chomp(",")
  sql = ActiveRecord::Base.connection()
  sql.begin_db_transaction
  sql.execute("SELECT * FROM Administrators WHERE ([Administrators].[id] = #{params[:id]})");
  sql.execute("UPDATE Administrators SET #{attrs_to_update} WHERE ([Administrators].[id] = #{params[:id]})");
  sql.commit_db_transaction
  render :json => @administrator.to_ext_json(:success => @administrator.update_attributes!(params[:administrators]))
end

# DELETE /administrators/1
def destroy
  Administrators.delete(params[:id])
  head :ok
end

Any thoughts on how to clean this up? Or again why it wouldn’t be working out of the box in the first place? 🙂

BUMP:

Really? Somebody’s got to have tried this…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:18:17+00:00Added an answer on May 12, 2026 at 10:18 am

    This is not a great answer to this question, but I think it’s the bottom line:

    • Don’t use MS SQL, Extjs and Rails, unless you feel like burning time and money trying to get them to cooperate. Try MySQL or PostGRE instead.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.