w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
When should SQL server connection be closed in a script?
You don't have to do them at all. After header('Location... you should use exit immediately. Open connections are closed when the script exits automatically. You could manually close them and use exit after that, though. You only need to worry about manually closing the connections if you're running out of connections during long-running scripts, but you may have other problems at that point.

Categories : PHP

Client prints Half Data Before Connection is Closed By Server on Socket
try flush data after sent. it needs if you use socket with fdopen FILE *fdsock = fdopen(sock, "a+"); ... fwrite(fdsock, 1, 1 "A"); fflush(fdsock); ... fclose(fdsock); and to finish socket, close with shutdown(sock, SD_SEND); UPDATE Take memset out of loop

Categories : C

How to import data via post deployment script from SQL Server CE into a SQL Server DB freshly created using VS database project
1) Is it possible to reference a SQL Server Compact database (sdfDB) in T-SQL script? If you are thinking to something like this, INSERT INTO [SQL SERVER Db].Table (Values) SELECT (Values) FROM [Sql Server Compact Db].Table unfortunately no, this is not possible. 2) If not, what is the best practice to import data into a freshly created DB from an embedded datasource which can be deployed by build script in a remote machine. You can use the SQL Server Compact Toolbox, that contains features to generate scripts from a Sql server compact file, that you can use to populate the SqlServer database. Features: Script! Migrate a SQL Server Compact database directly to SQL Server (LocalDB/Express) Migrate from SQL Server Compact to SQL Server, SQL Azure and SQL

Categories : Visual Studio 2012

App script access to data when loading data in speadsheet via HTML import
As you noted, there's no trigger that will tell you when a spreadsheet recalculation has completed. (That's what is going on after you update a formula in a cell.) You can induce your script to wait 10 seconds by using Utilities.sleep(10000);. Generally it's bad programming practice to rely on delays, but it's almost your only option here. The other option would be to perform the html query yourself, parse the table of data into an array, and write it to the new sheet. If you're interested in that, have a look at html div nesting? using google fetchurl, to see how you could obtain your table of information.

Categories : Google Apps Script

How can I schedule hourly request to a server and store data on my own server to access from iOS app?
Good question, I recently had to learn a bit on the server side for the push notifications i'm trying to implement in a market data (fx) app i'm writing. The best solution i've found is: Assuming you're on a Mac, Get MAMP here - it's PHP, MySQL and Apache webserver. best bit about MAMP is it's a self contained app, so it won't mess with your OS X install You can write PHP code to pull the data from the API, store it on your MySQL database you set up with MAMP. You can then write a little objective C code, to hit up your Apache webserver on another PHP file that pulls the data you stored earlier. That's basically it, now I know what you're thinking, you probably don't know any PHP. Either did I until last weekend and you should see what I'm able to do in it now! I only knew obj

Categories : Iphone

google api - server to server auth can access but not expected data
Ok I discovered the problem. THe server to server authentication creates a unique id ad email for the access. To access data on my main google account as expected I need to add this email account to the calendars authorised users from within the calendar settings. When you set up the server to server key the user_email will look similar to: xxxxxxxxxxx@developer.gserviceaccount.com Go into calendar, settings and then under each calendar > calendar settings > calendars change the sharing options. Add this email address and set appropriate user access I've now been able to access the calendars with the server to server access and the key! Thanks to this post for the clues:Service Applications and Google Analytics API V3: Server-to-server OAuth2 authentication?

Categories : PHP

Access UNIX server and run a shell script from java application
You could use SSH component JCraft for remote connection and shell commands invocations: import com.jcraft.jsch.* Exerp from my old code: JSch jsch = new JSch(); String command = "/tmp/myscript.sh"; Session session = jsch.getSession(user, host, 22); session.connect(); Channel channel = session.openChannel("exec"); ((ChannelExec)channel).setCommand(command); channel.setInputStream(null); ((ChannelExec)channel).setErrStream(System.err); InputStream in = channel.getInputStream(); channel.connect(); byte[] tmp = new byte[1024]; while (true) { while (in.available() > 0) { int i = in.read(tmp, 0, 1024); if (i < 0) { break; } System.out.print(new String(tmp, 0, i)); } if (channel.isClosed()) { if (channel.getExitStatus() == 0) {

Categories : Java

Can a mobile service server script (schedule) access other Sql Azure databases?
Yes you can. You need to connect using the following example (uses Node.js) taken from the how-to guide: To use the node-sqlserver, you must require it in your application and specify a connection string. The connection string should be the ODBC value returned in the How to: Get SQL Database connection information section of this article. The code should appear similar to the following: var sql = require('node-sqlserver'); var conn_str = "Driver={SQL Server Native Client 10.0};Server=tcp:{dbservername}.database.windows.net,1433;Database={database};Uid={username};Pwd={password};Encrypt=yes;Connection Timeout=30;"; Queries can be performed by specifying a Transact-SQL statement with the query method. The following code creates an HTTP server and returns data from the

Categories : Javascript

How do I access the data sent to my server using BaseHTTPRequestHandler?
Give this a try. I stole it from an answer to another question def do_POST(self): ctype, pdict = cgi.parse_header(self.headers.getheader('content-type')) if ctype == 'multipart/form-data': postvars = cgi.parse_multipart(self.rfile, pdict) elif ctype == 'application/x-www-form-urlencoded': length = int(self.headers.getheader('content-length')) postvars = cgi.parse_qs(self.rfile.read(length), keep_blank_values=1) else: postvars = {} print(postvars.get("listName", "didn't find it"))

Categories : Python

unable to access variable declared in ksh script to csh script using shell script
The ksh script is not doing what you think it is doing when used by ksh; it sets $1 first to MyUser=root and then MyPassword=shroot. However, when you source it from your C shell script, because the syntax is compatible with C shell (checked with tcsh), you would set the two variables. If you sourced the script from a Bourne-shell derivative, the exit at the end of the ksh script would cause the shell to exit; it does not seem to cause the C shell to exit. So, what you've got is a weird hybrid. Normally, you stick to one language and use it exclusively. Where you need to use another shell, you can do so, but you simply run the script written for the other shell. You can communicate to the other script with environment variables. You don't normally try writing sourceable code that ca

Categories : Shell

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

Attempted to access a cursor after it has been closed
In your finally block, you close the cursor, but you do not set it to null. Thus, the next time your method is called, cursor.getString(3) fails, since the cursor has been closed. Workaround: Set cursor to null in your finally block. Correct solution: Don't use an instance variable for your cursor, use a local variable in your method instead.

Categories : Android

DotNetZip - Cannot access a closed Stream
It seems that calling Save is the point when the source streams are read. This means you have to keep them undisposed until after the save. Abandon using statement in this case as it is impossible to extend its scope beyond the loop. Instead, collect your IDisposables and dispose of them once the save is completed. result = new MemoryStream(); using (ZipFile zipFile = new ZipFile()) { List<IDisposable> memStreams = new List<IDisposable>(); try { for (int i = 0; i < files.Count(); i++) { System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); Byte[] bytes = encoding.GetBytes(files[i]); MemoryStream fs = new MemoryStream(bytes); zipFile.AddEntry(fileNames[i], fs); memStreams

Categories : C#

How to fetch data from a different sql server database without having access?
It can work, but you have to do a few things to get there. Here's the easiest way (though not necessarily the best): Set the owners of both Databases to 'sa'. Turn on CROSS-DATABASE chaining for both databases. Turn on TRUSTWORTHY for the source database (B). Edit the Trigger and add WITH EXECUTE AS OWNER before the FOR clause. Note that while this works, it has significant security considerations (particularly #2 and #3). Here is a link that explains this and some other methods and some of the security issues: http://msdn.microsoft.com/en-us/library/ms188304.aspx

Categories : Sql Server

Data transfer From access to MSSQL server
You can use Data Import from SSMS. Right click on DB select Tasks Import data.. Select your Access DB as source Set the mappings etc from your source to destination You can save this as an SSIS package to either re-run at a later date or to develop in BIDS for a more advanced import toolset.

Categories : Sql Server

Transfering data from access database to SQL server
I found that I could open the databse, then open the SQL Server. Pull the records then close them at the same time. DatabaseConnection.Open() 'SQL statement for find the records that need to be transfered. Dim SQLCommand2 As New OleDbCommand("SELECT * FROM b_forte WHERE BaleLine = '" & stBaleLine & "' and ProdDate > #" & GlobalVariables.dtLastBaleDateTime & "#", DatabaseConnection) Dim TransferRecord As OleDbDataReader = SQLCommand2.ExecuteReader() If ApplicationPropertiesWindow.DisplayCodechkbx.Checked = True Then MainTextBox.AppendText(Environment.NewLine & "SELECT * FROM b_forte WHERE BaleLine = '" & stBaleLine & "' and ProdDate > #" & GlobalVariables.dtLastBaleDateTime & "#") GlobalVariables.DisplayCode = True

Categories : Dotnet

Transforming data taken from Access in SQL Server 2008 R2
What you asked can be done like this: WITH CTE AS ( SELECT ID, 1 AS RN, '<' + ID + '><' + Name + '>' AS Tag FROM Table1 UNION SELECT ID, 2 AS RN, '</' + ID + '></' + Name + '>' AS Tag FROM Table1 ) SELECT Tag FROM CTE ORDER BY ID,RN SQLFiddle DEMO However if those are to be valid xml tags you might actually want to switch the order of tags in closing row? WITH CTE AS ( SELECT ID, 1 AS RN, '<' + ID + '><' + Name + '>' AS Tag FROM Table1 UNION SELECT ID, 2 AS RN, '</' + Name + '></' + ID + '>' AS Tag FROM Table1 ) SELECT Tag FROM CTE ORDER BY ID,RN SQLFiddle DEMO Also, single row might also work for you? SELECT '<' + ID + '><' + Name + '></' + Name + '><

Categories : SQL

Use a Public Method of a Closed Form in MS Access
You may be able to do what you want by using the name of the form's code module to qualify the procedure call. For example, my Form7 includes a public sub, SayHello, which simply does ... MsgBox "Hello " & CurrentUser As you're aware, I can call that procedure when the form is open like this ... Forms!Form7.SayHello When the form is closed, I can still call the procedure like this ... Form_Form7.SayHello Although the form is not displayed, that approach does add it to the Forms collection and leave it there afterward. So I would have to explicitly remove it. DoCmd.Close acForm, "Form7" However, if that approach is acceptable for your purpose, it may not work, depending on the specific details of your procedure. Mine is trivial, so no problem. In actual practice, I pre

Categories : Forms

Get access to xml parts of a CLOSED excel workbook - how
If I understand the question this should help you: Dim WB As Workbook Application.ScreenUpdating = False Set WB = Workbooks.Open(FileName, ReadOnly:=True) [ ... do your stuff with WB ... ] WB.Close False Application.ScreenUpdating = True The file will be open, but it will be fast because it's open read only (much faster than with write permission) and there is no UI update (often the slowest part of any VBA macro).

Categories : Xml

Access Owncloud data files stored same server from php
I assume you try to load the image directly via a url pointing to the files location inside the owncloud file structure? owncloud will prevent this, in the end you are trying to access internal or private data via a public url. That would be a huge security flaw. If the image is inside a users file hierarchy inside owncloud then you can access it using the "official" link, as long as it is shared by the user. The only workaround would be to use administrative means on server level. This is of course something the owncloud software cannot prevent. If you have those rights you can create a second Directory / Location inside the http servers configuration to provide a second base url publishing those files. This would access the file system whilst bypassing the owncloud software. But take

Categories : Image

Creating MVC 4 data access layer using SQL Server 2000
Technically speaking, MVC has nothing to do with your DAL. As far as your MVC app is concerned, it shops at the repository layer and does not care what happens in the warehouse (data layer). Your DAL can be built using ADO.NET. Although this technology is old, its perfectly usable. If you check out http://www.dofactory.com/Default.aspx, you will see an app that is build using multiple DAL technologies. One is for Entity Framework and another is for ADO.Net ... and the cool part is they are BOTH hitting the same database.

Categories : Asp Net Mvc

storing data in server memory for website access
Store it in the Cache. You're still going to run into an issue of first-load slowness as it reads from DB and into Cache, but that's impossible to avoid. You can put it in the Application_Start event to guarantee it happens the first time the app is loaded. http://msdn.microsoft.com/en-us/library/dd997357.aspx

Categories : Asp Net

Bash script with telnet "connection closed by foreign host"
Your box may have access restrictions that make it disallow connections from the machine you're running the script on. As general advice: do quote $line to prevent nasty things from happening, as in: echo 'foo'"$list"'bar' (notice the double quotes); instead of telnet, which is meant more for interactive usage, use nc (netcat): echo 'stuff' | nc -n 192.168.1.82 49153; this may help with your connection issues, if your telnet is trying to be smart and negociate telnet protocol specific parameters before it sends your data through; since you only use one command, echo, to send data, you don't need to run it in a subshell, so the parentheses ( ) are not needed; when you have multiple lines to output, consider using cat <<EOF instead of echo (look up here-documents in the bash manual)

Categories : Bash

How to do jQuery DataTables server side data with Google Apps Script
The easy way: get all the data at once. like this In GS Code add function function getData(){ var data = SpreadsheetApp.openById('YourSheetID').getSheetByName('YourSheetName').getDataRange().getValues(); return data; } In HTMLtemlate: <script type='text/javascript'> $(document).ready(function(){ var runner = google.script.run.withFailureHandler(onFailure); runner.withSuccessHandler(onSuccess).getData(); }); var onSuccess = function(data){ var aDataSet = data.slice(1); // all except header var head = []; // headers data[0].forEach(function(e){ head.push({'sTitle': e}); }); $('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table&g

Categories : Jquery

Java Script get data from server (asp.net) and save it in local storage (client side)
You are trying to throw in an object into localStorage Change localStorage.setObject("teamworkGantDemo", prj); to localStorage.setItem("teamworkGantDemo", JSON.stringify(prj)); or simply localStorage["teamworkGantDemo"] = JSON.stringify(prj) But if you are insistent on using a wrapper around this, you could do this : Storage.prototype.setObject = function(key, value) { this.setItem(key, JSON.stringify(value)); } Storage.prototype.getObject = function(key) { return JSON.parse(this.getItem(key)); } Then use it this way : localStorage.setObject("teamworkGantDemo", prj);

Categories : Javascript

TimerTask causing "Access closed cursor" force close
That's not appropriate way. If you are used cursor as a global variable then you can used in runOnUiThread but my opinion is you have to used cursor this way. //get the record in cursor if(Cur.getCount()!=0){ if(Cur.moveToFirst()){ do{ //here you can manipulate your record }while(Cur.moveToNext()); } } Cur.close(); This is perfect way try and run.

Categories : Android

Sails.js: How To Access Data in Server-Side EJS View for Single Model
You can create controller action that matches the route and manually pass found model to the view. In UserController: find: function(req, res) { User.findOne({'id': req.params['id']}, function(err, user) { res.view({user: user}) }) } Then You can reference this model in views/user/find.ejs: <%- user.id %> <%- user.name %>

Categories : Misc

.NET SQL Server connection being prematurely closed
The simplest thing to do would be to check the connection state and open it if necessary: if(conn.State == ConnectionState.Closed)//Can't quite remember the exact syntax { conn.Open(); } //do DB stuff here.

Categories : Sql Server

TCP server socket is closed if i switched to another app
In android, the decision whether to keep your app running or not depends a lot on the existence of a Context whether it is an Activity, Service or BroadcastReceiver. According to android's documentation: An empty process is one hosting no activities or other application components (such as Service or BroadcastReceiver classes). These are killed very quickly by the system as memory becomes low. For this reason, any background operation you do outside of an activity must be executed in the context of an activity BroadcastReceiver or Service to ensure that the system knows it needs to keep your process around. So what do you want to do is starting a service once your activity is started and from that service spawn a thread that will manage the TCP server. that way you will be fine as l

Categories : Java

determine if client has closed connection to server using socket
Here is some code I believe can be used to detect exiting socket... Originator of this code was stated as Andrew Gillard no other licence information was available... <?php $host = '127.0.0.1'; $port = 7010; gc_enable(); set_time_limit(0); function socketError($errorFunction, $die=false) { $errMsg = socket_strerror(socket_last_error()); echo $errorFunction.' '.$errMsg." "; if ($die) die("Program Ended "); } //Attempt to create our socket. The "@" hides PHP's standard error reporting, if (!($server = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) socketError('socket_create', true); //socket_set_option($server, SOL_SOCKET, SO_REUSEADDR, 1); if (!@socket_bind($server, $host, $port)) socketError('socket_bind', true); if (!@socket_listen($server)) socketError('socket_list

Categories : PHP

Server dies on `send` if client was closed with Ctrl+c
When you call send() on an already closed connection, the operating system may issue SIGPIPE to your process. Usually the default handler for SIGPIPE is to kill your process. In order to prevent this from occurring, you can either ignore the signal (e.g., with signal(SIGPIPE, SIG_IGN) or sigignore(SIGPIPE)), or you can pass the MSG_NOSIGNAL option to send(): int send_result = send(newfd, ok, 3, MSG_NOSIGNAL); if (send_result >= 0) { /* okay, but check if all your data got sent! */ if (send_result < 3) /* ...do something */; } else { switch (errno) { /* ... */ case EPIPE: /* sending on a closed connection... */ } } Now, instead of issuing SIGPIPE, the send() call will fail, and errno will be set to EPIPE.

Categories : C

application crashes if the server is closed due to timeout. How can I catch it?
Please try the following public String getData(String url) { HttpClient httpclient = new DefaultHttpClient(SetHttpParams.setHttp( 50000, 50000)); HttpGet httpget = new HttpGet(url); HttpResponse response; try { response = httpclient.execute(httpget); if (response.getStatusLine().getStatusCode() == 200) { org.apache.http.HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); String res = Functions.convertStreamToString(instream); } } } catch (ConnectTimeoutException e) { } catch (SocketTimeoutException e) { } catch (IOException ex) { } } String res is your string where the response will be stored

Categories : Android

Fatal: Server unexpectedly closed network connection
The command is working fine for me. However, your question suggests that you're trying to connect to an FTP server. WinSCP can handle both SCP/SFTP and FTP connections, but to my knowledge psftp supports only SFTP (a file transfer protocol based on SSH, not to be confused with FTPS). If your server is not an SSH server, you need an FTP client for the data transfer (e.g. ftp.exe shipped with Windows). If your server is an SSH server, try running psftp with the option -v to get more information, and also check the logs on the server.

Categories : Powershell

SQL Server session stays open when application is closed
Entity framework uses the underlying SQL Server ADO.NET provider which pools database connections as they are an expensive operation to create and flush each time. You can flush the connection pool using a SqlConnection.ClearPool method call on your Application_End event handler. Note: I would not recommend disabling or flushing the connection pool for production code. An alternate method for development can be to modify to disable pooling via you connection string using the Pooling=false option.

Categories : C#

Run a python socket server and if closed remotely start it listening again
The way you usually program a threaded socket server is: call accept() in a loop spawn a new thread to handle the new connection A very minimal example would be somethig like this: import socket import threading import time server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind(('0.0.0.0', 9999)) server.listen(1) def handle(conn): conn.send(b'hello') time.sleep(1) # do some "heavy" work conn.close() while True: print('listening...') conn, addr = server.accept() print('handling connection from %s' % (addr,)) threading.Thread(target=handle, args=(conn,)).start() You're spawning new threads in which you create your listening socket, then accept and handle your connection. And while socketIsOpen is True your programm will be using a lot of

Categories : Python

Catch the exception thrown at client side when the server closed the pipe
the most common way to know that the other side is dead is the "echo": once in a while(let's say every 10 seconds) the client sends an "echo" - meaning a simple request to the server to get replay. if 3 echo in a row(could be more, depend on you) did not answered by the server, the client decide that the server is down and disconnect his side

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

Access session variable that is set in Script 1, in Script 2. PHP
PHP session changes aren't written to the session storage by default until the end of the program; while the program is running, $_SESSION is just like any other variable; only accessible within its own program; it's only when the program ends and the session is written to disk that the next program can get at the changes you've made to the session data. So the short answer is that you won't be able to do this just by checking the session and expecting the latest updates to be there. You can force PHP to write to the session at any time during the program by using the session_write_close() function, but as you may gather from the function name, this will also close the session to that program, so that program can't make any further updates to it. I guess you could then re-open the sessio

Categories : PHP

How to save data when a program is closed
I typically create XML files to store parameter fields that require saving. http://www.dotnetperls.com/xmlwriter It works well enough when you've not got sensitive material and you need to get parameters back without much heavy parsing.

Categories : Visual Studio 2010

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



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