w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
My code gives me and error called "There is already an open DataReader associated with this Command which must be closed first"
Try to use a new connection instead in the sqldread.Read() SqlConnection conn2 = new SqlConnection(); conn2.ConnectionString = ""; //your connection string SqlCommand scmd1 = new SqlCommand(QueryStr, conn2); scmd1.Parameters.Add("@Image", SqlDbType.VarBinary).Value = imgbytes; conn2.Open(); scmd1.ExecuteNonQuery(); conn2.Close();

Categories : C#

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

How to write rspec testing without database in ruby for this ruby code
Here's a short example of testing the validations on an ActiveRecord model. You can certainly go into much more depth, and there are plenty of ways to make the tests more elegant, but this will suffice for a first test. describe Person do describe "#name" do specify { Person.new(:name => "Short").should_not be_valid } specify { Person.new(:name => "Long" * 12).should_not be_valid } specify { Person.new(:name => "Just Right").should be_valid } end end

Categories : Ruby

Running some code when browser is closed
In my knowledge it is impossible to detect a browser close separately from a browser navigation. the browser does not provide the window with that information. SEE HERE ALSO

Categories : Javascript

Executing code when my form is closed
I think that what you need is not access to the close button, but rather access to the event which is fired when the form is closed. Taken from this previous SO post, what you might need is something like so: void FormClosed(object sender, FormClosedEventArgs e) { // do something useful }

Categories : C#

Error with OracleDataReader. Error: Invalid operation. The connection is closed
You should open the connection and you should also use sql-parameters. Hopefully this is the correct oracle syntax because i cannot test it: using(var con = new OracleConnection("ConnectionString Here")) using(var cmd = new OracleCommand("ADD YOUR INSERT/UPDATE/DELETE", con)) { con.Open(); cmd.ExecuteNonQuery(); using (var cm = new OracleCommand("select round(avg(rating),1)As AvgRating from rates where id_rec = @id", con)) { cm.Parameters.AddWithValue("@id", id); using (var reader = cm.ExecuteReader()) { if (reader.Read()) { textBox5.Text = reader.GetInt16(0).ToString(); } } } } Note that i have used the using-statement to ensure that all unmanaged resources are disposed as soon as po

Categories : C#

How to execute code when a Python script is closed out?
import MySQLdb con = MySQLdb.connect(...) cursor = con.cursor() try: # do stuff with your DB finally: con.close() The finally clause is executed on success as well as on error (exception). If you hit Ctrl-C, you get a KeyboardInterrupt exception.

Categories : Python

VBA code crashing Excel if closed early
For non english languages, you could use .FormulaLocal or .FormulaR1C1Local. Developer reference says "Returns or sets the formula for the object, using R1C1-style notation in the language of the user. Read/write Variant". However, I strongly recommend not using the above, as it will mean it won't work if the macro is run on a different language version. Instead, better practice is to use English in conjunction with .Formula and .FormulaR1C1. This will still open as French in a French version, as Excel automatically displays formulae text in the relevant language. For example: (I use "FALSE" only as an example - the below is true for formulae too like "=SUM(A1)", and of course, if you really want to set a boolean value then please don't use string "TRUE"!) ActiveCell.Formula = "FALSE"

Categories : Excel

Getting ResultSet is closed exception but i didn't close it in the code
You're closing the statement - that will close your result set too. From the docs for ResultSet: A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results. You should extract all the relevant data from the result set immediately, then close it (and the statement and the connection) in finally blocks - or using the try-with-resources statement in Java 7. I'd also strongly suggest that you separate your UI code from your data access code. (Your current "UI" also appears to be a mixture of a console app (System.out.println) and Swing, which is odd...)

Categories : Java

Code after showDialog is not execute when the modal window is closed by the other thread -- C#
Unless you have a long running or slow operation, there is no reason why you should complicate your life with a separate thread. Just show your dialog form in modal mode and proceed when the user has input the required data.

Categories : C#

Replace near working array code with hash code in ruby to find mode
This seems to fit your requirements: def mode(array) histogram = array.each_with_object(Hash.new(0)) do |element, histogram| histogram[element] += 1 end most_frequent = histogram.delete_if do |element, frequency| frequency < histogram.values.max end most_frequent.keys.reduce(&:+) / most_frequent.size.to_f end It creates a hash of frequencies histogram, where the keys are the elements of the input array and the values are the frequency of that element in the array. Then, it removes all but the most frequent elements. Finally, it averages the remaining keys.

Categories : Ruby

How to add custom code in mailers ? adding ruby code in @message variable
Move this into mailer template into app/views/email_mailer dir & into YOUR_MAILER_NAME_HERE.html.erb file <%= @message %> <%= link_to 'Home Page!', root_url %>

Categories : Ruby On Rails

Why does this code work in ruby 1.8 and not ruby 1.9?
It's to avoid ambiguity. Consider the following: def foo(a, b = 1) # foo takes an optional second argument end [foo 1, 2] This could be interpreted as [(foo 1), 2] or as [(foo 1, 2)]. There are two references in the Calling Methods docs (although not directly related to the array literal): Note that the parenthesis are optional ... Except when there is difference between using and omitting parentheses In many cases parenthesis are not necessary when sending a message ... However, parenthesis are necessary to avoid ambiguity.

Categories : Ruby

CsvParser Stream Closed Error
The CsvParser is lazy, so reads rows as they are requested (rather than loading them all into memory. The withReader call closes the Reader once the Closure is finished. So when you try to do csvFile.each, the stream is closed. This should work: new File("file.csv").withReader { def csvFile = CsvParser.parseCsv( it ) csvFile.each { println it } }

Categories : Csv

Connection is closed error with SqlTransaction
try by opening connection before BeginTransaction using (var con = new SqlConnection(cs)) { con.Open(); SqlTransaction tran = con.BeginTransaction(); // rest of the code

Categories : C#

changed closed error while doing git push
use $git stash to reset your code to the previous HEAD. Please take a backup of your code somewhere else because it will undo all the changes since last commit. After running git stash; your repo will be pointing to previous commit, now you can merge your latest changes in it then push your changes on the server.

Categories : Android

ResultSet is Closed Error on retrieval
You need to first call rs.next() to make sure that resultset cursor is pointing to the first record in the returned ResultSet. So, replace the below call: ret = rs.getInt("frequency"); with : if(rs.next()){ ret = rs.getInt("frequency"); }

Categories : Java

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

Underlying connection closed error in WCF client
WCF is a message-based system using XML-serialized messages to communicate between client and server. This means that WCF messages have to be in such a way that they can be expressed in a XML schema and thus packaged up into a XML message. WCF is not a remote procedure call system, e.g. there is no "live" connection at runtime between the client calling the server - the client just send a request as an XML message to the server, and the server responds by sending back another XML message containing the response. This also means: you can only use explicit concrete types - no interfaces. And it also means: no generics. So IEnumerable<VehicleTypes> is not good for two reasons: generics and interfaces. You will need to create a VehicleCollection type on your server-side, and use that

Categories : Asp Net Mvc

Missing ) in parenthetical error, but everything seems to be closed off properly
Your – characters are atually U+2013 EN DASHes, which are not legal in Javascript. You need to use U+002D HYPHEN-MINUS instead.

Categories : Javascript

Stream Closed error in twitter4j how to solve
Twitter gives the following reasons why you may be disconnected: A client establishes too many connections with the same credentials. When this occurs, the oldest connection will be terminated. This means you have to be careful not to run two reconnecting clients in parallel with the same credentials, or else they will take turns disconnecting each other. A client stops reading data suddenly. If the rate of Tweets being read off of the stream drops suddenly, the connection will be closed. A client reads data too slowly. Every streaming connection is backed by a queue of messages to be sent to the client. If this queue grows too large over time, the connection will be closed. A streaming server is restarted. This is usually related to a code deploy and is not very fre

Categories : Java

Ruby code understanding - From code School
Search should be instance of Regexp or nil. In first line search is setting to blank string if it's equal to nil initially. In third string matched_games is setting to array of strings matched to given regex (http://ruby-doc.org/core-2.0/Enumerable.html#method-i-grep)

Categories : Ruby On Rails

The underlying connection was closed: An unexpected error occurred on a receive. while Using WCF
First of all check your web.config setting for executionTimeout and maxRequestLength on both side WCF and your MVC4 client. for more information on this please refer this below link there is a good answer given by jlchereau, follow this steps and try to check it out again, it might help you out. also try to enable WCF tracing (Tracing) and find out the root of exception it will help you a lot to resolve your issue. http://velodocaddin.codeplex.com/discussions/40792

Categories : Wcf

Stream Closed error on Tomcat 7 with Clojure Compojure Application
I often encounter such situations, where something works in development and fails in production, when a call to the DB is returning a lazy sequence of records, which is being printed to the repl or logger in development and not being realized on the production system. It could be that something in the call to get-productivity is missing a call to doall around the returned rows. Another case is where the exception handler is wrapping around a call to with-connection so when the exception happens the db connection is not longer available, though this seems less likely than a missing doall based on my guess of what could be in get-productivity if you include get-productivity and log an example of it's return value during the failure we will be able to make better guesses.

Categories : Tomcat

Solr error : Undefined method Closed? for nil class, in port 8981
To overcome this problem what I did was : created a copy of file solr as solr_qa under /etc/init.d and configured its paths to the qa application's .. /vendor/plugins/acts_as_solr/solr. Then started the solr with the new file: /etc/init.d/solr_qa start also restarted conf file /etc/init.d/httpd restart And my job was done.

Categories : Ruby On Rails

Fatal error: Uncaught AwsGlacierExceptionGlacierException: AWS Error Code: , Status Code: 400, AWS Request
It seems you may be confused about the difference between vaults and archives. You should make sure to look through the Amazon Glacier Developer Guide to become familiar with the basic concepts of Glacier. You must first create a vault in order to upload archives to it. A vault in Glacier is similar to a bucket in S3. You should also check out these links which provide code samples for doing uploads with Glacier: Uploading Archives to Amazon Glacier from PHP blog post on the AWS PHP Developer Blog "Amazon Glacier SDK php" post on SO

Categories : PHP

How to draw closed spline 3D (closed curve 3d) through unordered list of points3D. How to arrange points3D?
It sounds like you're looking for the Concave Hull of the data set. Unfortunately, I don't know of any pre-canned algorithms, but the link references a paper that another developer was starting from, as well as some sample code, so maybe that'll help you in the right direction.

Categories : C#

"An existing connection was forcibly closed by the remote host" sporadic error from HttpWebRequest
You could have dangling connections, and in HTTP 1.1 you are limited to 2 connections. Try changing the HTTP Protocol Version used in the request: request.ProtocolVersion = HttpVersion.Version10; If that doesn't work, it could be taking a long time to resolve the proxy settings, which can be fixed by disabling the proxy settings in your application by adding the following to the .config file: <system.net> <defaultProxy enabled="false"> <proxy/> <bypasslist/> <module/> </defaultProxy> </system.net> If either of the above fixes the problem, I'd recommend adding a try...catch...finally block around your request code, to ensure that each request is properly closed and disposed of (try setting request = null in your finally statem

Categories : Asp Net

Fatal execution error when a file is opened, closed and disposed multiple times in C#
Random crashes and FatalExecutionEngineError exceptions are normally associated with stack or heap corruption which can remain hidden until further down in your code. Ensure that you have marshalled all your C++ functions correctly using the right calling convention, parameter types and return types. Microsoft specifies the probable cause of the message is: The CLR has been fatally corrupted. This is most often caused by data corruption, which can be caused by a number of problems, such as calls to malformed platform invoke functions and passing invalid data to the CLR. Judging from the code you've supplied, your declaration looks correct so it could be another function that you've marshalled that is causing an issue. Ensure that your C++ code is stable and not the cause of

Categories : C#

runtime error 2467: The expression you entered refers to an object that is closed or doesnt exist
Pretty sure it should be Set objOtherTbls = Application.CreateAdditionalData() and not Set objOtherTbls = Application.CreateAdditionalData as you are calling a method.

Categories : Vba

ERROR: Error installing jquery-rails: activesupport requires Ruby version >= 1.9.3. in Ubuntu 10.04
sudo gem install jquery-rails is probably using your system's built-in Ruby (which is likely 1.8, or 1.9.2). This is because you're using sudo. With RVM, get rid of the sudo and it'll use RVM instead: gem install jquery-rails

Categories : Ruby On Rails

what does this ruby code mean?
No, @user_pages and @users are two different values returned from an array of values. They are, in effect, value[0] and value[1]. An irb example should help: MacBook-Pro:~ me$ irb 1.9.3-p429 :001 > a,b = [1,2] => [1, 2] 1.9.3-p429 :002 > a => 1 1.9.3-p429 :003 > b => 2

Categories : Misc

Why do I get an "Error running 'autoreconf'" error using RVM to install ruby-2.0.0-head?
managed to fix the issue. It was a perl version problem. The autoconf log was saying something like "This perl not built to support threads". I had an older version of perl: $ perl --version This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-multi-2level I did 'sudo port upgrade perl5' and after it successfully updated everything went smoothly. Thanks for the help everyone! :)

Categories : Ruby On Rails

Error installing Ruby on Rails 4.0.0 - error compiling atomic_reference.c
I had this exact same problem today. I was able to fix it, but I'm not entirely sure what caused the problem initially, or even how I solved it. What I do know is it finally worked after I updated ruby gems to the latest version, instead of getting version 2.0.0 as the tutorial suggests. gem update instead of gem update --system 2.0.0 Try that and let me know if it helps.

Categories : Ruby On Rails

ruby on rails error (webpage has a redirect loop error)
the problem is with a method called config_value NoMethodError (undefined method config_value' for nil:NilClass): app/controllers/application_controller.rb:319:inset_user_language' so check your application_controller.rb on line 319 and post what's there EDIT: in your code (line 319), you're calling config_value on lan - but the error message is saying that lan has a nil value - so config_value can't be called on it. earlier you have lan = Configuration.find_by_config_key("Locale") - so i'm guessing that rails can't find a config_key called "Locale" - but really I'm not sure. Did you write this code or was it generated by a gem?

Categories : Ruby On Rails

The underlying connection was closed: The connection was closed unexpectedly wcf service
The first thing i will do is, instead of returning the full list of candidates i will return an empty list. If that works fine, then it is very clear that the size of the data is a problem. To modify the size play with your binding parameters.

Categories : Wcf

Do I need to indent my code in Ruby?
Ruby is not whitespace sensitive. Your code, although not pretty, will work. However: http://www.ruby-forum.com/topic/56039 irb(main):001:0> a = ( 4 + 5 ) => 9 irb(main):002:0> a = ( 4 irb(main):003:1> + 5 ) => 5 irb(main):004:0> a = ( 4 + irb(main):005:1* 5 ) => 9

Categories : Ruby

why is my code returning nil in ruby?
In your initialize method, you're overwriting the hash that is passed into the function. def initialize(f) f = Hash.new @f = f end should be something like def initialize(f={}) @f = f end

Categories : Ruby On Rails

How to understand this ruby code?
But I don't know what :starting and :finishing in line 1 & 2 mean :starting and :finishing are the hash keys of the hash procs. what :starting=> in line 3 and :finishing=> in line 4 mean. You are sending a Hash object as an argument via the method callbacks. Read here Hash.

Categories : Ruby

How to DRY up repetitive Ruby code?
All you need is, before_save :sanitize_phone_number_fields def sanitize_phone_number_fields [:primary_phone, :secondary_phone, :fax].each{|attr| self.send(attr).gsub!(/D/, '')} end

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.