DBI stateHandler bind_param errors

I have a real problem with calling a stored procedure on MS SQL Server
from Ruby-DBI. I have no problems with connections or calling queries.
I can even call the Stored procedure with “exec Test ‘test’” and the
stored procedure inserts the value text into a Test table. However, if
I try to use the bind_param to add the input params to a stored
procedure to make my class alitte more friendly it ERRORs.

OUTPUT ____
Connection Successful !!!
Preparing SQL Query: exec Test
Executing SQL Stmt
Error INTERN (0) [RubyODBC]Too much parameters


CODE ____________

begin
  connection_string = "DBI:ODBC:Driver={SQL

Server};Server=#{@adapter_config[“acct_db_host”]};Database=#{@adapter_config[“acct_db_name”]};Uid=#{@adapter_config[“acct_db_user”]};Pwd=#{@adapter_config[“acct_db_pass”]}"
connect( connection_string, @adapter_config[“acct_db_user”],
@adapter_config[“acct_db_pass”] )
is_connected
prepare( “exec Test” )
bind_param( 1, “Admin1” )
execute
#puts "Return_Code: " + get_return_code
#puts "Return_Status: " + get_return_status
rescue DBI::DatabaseError => e
puts “Error #{e.errstr}”
rollback
ensure
#disconnect from server
disconnect
end
end

def connect( connection_string, db_user, db_pass )
@db = DBI.connect( connection_string )
end

def disconnect
@db.disconnect if @db
end

def is_connected
if @db.ping
puts “Connection Successful !!!”
else
puts “Connection FAILED !!!”
end
#@db.ping
end

def execute
puts “Executing SQL Stmt”
@stmt.execute
end

def prepare( query )
puts "Preparing SQL Query: " + query
@stmt = @db.prepare( query )
end

attribs is not yet used in this version, but could later be a hash

containing more

information like parameter type, etc.

def bind_param( param, value )
@stmt.bind_param( param, value, false )
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs