As the question says:
How to access Microsoft SQL Server 2005 from Cocoa on Mac OS X 10.5?
The database driver should be free if possible, paid solutions can be OK as well.
If you use ODBC, Actual Technologies makes a Microsoft SQL Server driver for OS X:
http://www.actualtechnologies.com/product_sqlserver.php
Some Googling suggests this question:
http://lists.apple.com/archives/Cocoa-dev/2004/Jul/msg00077.html
Which points to these two apps:
http://www.freetds.org/
http://www.macosguru.de/
Do those meet your needs? If not, can you elaborate on the question? Thanks!
FreeTDS is pretty good and fairly easy to use from Objective-C as it has a C API.
However an even easier way is to use the jTDS JDBC driver via the Java bridge. I know that Apple no longer recommends using the Java bridge but it is probably the easiest way to talk to SQL Server and if you structure you code nicely pretty much any other database on the planet.
Commenting on this because this is one of the top results on a google search for adding SQL Server connectivity to a Cocoa (MacOS) app but I don't see any current solutions listed.
FreeTDS - as Daniel suggested, is the fastest/easiest way to go but some information about how to make that happen without using the dreaded Java bridge or some kind of Python hack. Build FreeTDS with Homebrew (don't for heaven's sakes try to build it on the mac yourself), then select your project in the Xcode finder, select the "build phases" tab, then under "link binaries with libraries" link the FreeTDS library libsybdb (use either the dynamic or static one). click on the "+" sign, then choose "add other" then navigate to where the libraries are - for me the directory the libs were installed in was
/usr/local/Cellar/freetds/1.00.109/lib
then select (e.g.) libsybdb.a in that directory
You can then use the FreeTDS API or use a wrapper like this one by Martin Rybak, which is what I did (I'm using an old version of this "SQLClient" code). It works fairly straightforwardly for a SQL Server instance on AWS, and predictably slightly more complicatedly for an Azure AWS instance - I needed to hack the wrapper since the wrapper code issues a "use db" command to azure after login which Azure won't accept - for azure the database has to be set during the connection - instead I added (using the newer code from GitHub):
DBSETLDBNAME(_login, [host UTF8String]);
in the SQLClient.m file, which I added to the section:
DBSETLUSER(_login, [username UTF8String]);
DBSETLPWD(_login, _password);
DBSETLHOST(_login, [host UTF8String]);
DBSETLCHARSET(_login, [self.charset UTF8String]);
and I commented out:
if (database) {
_returnCode = dbuse(_connection, [database UTF8String]);
if (_returnCode == FAIL) {
[self connectionFailure:completion];
return;
}
}
My app is swift-based so I use a bridging header, adding to it:
#import SQLClient.h
To use the lib, something like (pseudocode since I'm not in front of my code right now):
let client = SQLClient.sharedInstance()
//I'm using the older code which uses a delegate and not notifications callback
self.client!.delegate = self
self.client!.connect("database_network_address", username: "username", password: "password", database: "database_name", completion: { (success) -> Void in
if(success) {
print ("connection has succeeded")
// now do something with the connection
self.client!.execute("select * from table_name", completion: { (data) -> Void in
//... do something with the returned array "data" per the wrapper API
})
} else {
print ("connection has NOT been success")
}
})
Let me know if you have any questions on this. This absolutely works for a Cocoa app, I use my app to upload tons of data into an Azure SQL Server instance. Good luck!
Related
as the title says , I have implemented this deprecated function for some odbc 2.0 applications ,when one application start to connect a database via this odbc driver , shows the below error message
I have implemented SQLGetFunctions also ,so this deprecated API could be noted as already implemented.
I am really confused ,any help will be appreciated ,thanks a lot!
I can answer my own question .
The reason is odbc driver on windows is dll.So I need to export the api either by declspec(dllexport) or by dll_name.def file . I don't add the the API name to the def file,so driver manager panics.(I just developed the project halfway ,and not aware of the def file)
It is dumb ,indeed .But maybe it can help some novice like me ,who are not familiar with dll mechanism
I am thinking of using vb.net and fetch data from a cnc controller (FANUC) which has FOCAS libraries, it supports vb.net. Please let me know how to get the data from it and store it in a database wamp server
(Sorry my example is for the 32bit implementation, but the 64 bit should parallel it)
Please take a look at your Fanuc Focus API CD.
You should find a directory like this:
\Fanuc Focas2 Drivers & Libraries V4.20\Fwlib\Dot NET sample
In that directory there will be the file:
fwlib32.vb
Add this file to your project. It will define all the possible function imports that you can use in Focas (Later you can trip this down of course, but to get started learning this, just use this file)
Please check the MTConnect adapter and the Fanuc-MTConnect-Agent.
After you got data by the adapter, you could use vb.net to do the next.
Fanuc adapter in cpp:
https://github.com/mtconnect/adapter/tree/master/fanuc
you can find the compiled Fanuc adapter here:
https://www.trakhound.com/downloads [MTConnect Agent for Fanuc]
and open source hosted on GitHub for MTConnect Agent for Fanuc:
https://github.com/TrakHound/Fanuc-MTConnect-Agent
I'm writing a simple Delphi App to upload a few files to a SFTP Server. i thought i would be able to use a TIdFTP indy client but it seams as tho their is not an option for FTP Over SSH (SFTP) does anyone know of any Free / Open source Components for Delphi 2010 that would support FTP over SSH (SFTP). Due to security reasons im unable to use Active X controls so please do not respond with Active X solutions.
Thanks for the help,
Kyle
SFTP and "FTP over SSH" are two separate things, and neither involves SSL (as someone else has suggested). SFTP is a sub-protocol of SSH while "FTP over SSH" is good/bad ol' FTP tunnelled through an SSH connection with port forwarding.
Either way, what you're after is a Delphi SSH library. I was unable to find a free SSH library for Delphi and ended purchasing SecureBlackbox (http://www.eldos.com/), which is excellent by the way, although SecureBridge (http://www.devart.com) also looks pretty good.
1) SFTP is NOT FTP-over-SSH. Read the discussion here.
2) For SFTP there are no free Delphi components. You can use our SFTP client and server components for Delphi (part of SecureBlackbox product), which are supported and maintained commercial solution.
I've been using PuTTY's SCP command line utility, with catching it's standard out via the CreateProcess method.
IP*Works include SFTP component - http://www.nsoftware.com/products/component/sftp.aspx and registered user of Delphi XE a XE2 can download this from code central (ID: 28437, ID: 28012)
and for Synapse is in contrib dir demo of simple SFTP - http://synapse.ararat.cz/files/contrib/
And since October 2019, there's a DLL fork of PuTTY with Delphi units, please see
https://github.com/superflexible/TGPuttyLib
This was created to be able to achieve the highest possible transfer rates over SFTP. It's free and very easy to use (with examples).
Look at Synapse ( http://synapse.ararat.cz/doku.php/download ) suporting ssl protocole.
Exemple code: http://synapse.ararat.cz/doku.php/public:howto:tcpwithssl
Another secure connection component set is from nSoftware: http://www.nsoftware.com/ipworks/ssh/components.aspx
You get SSH Tunnel, and SFTP.
They also offer a full component set of SSL related items: http://www.nsoftware.com/ipworks/ssl/components.aspx
libssh2 (wriiten in C) supports SFTP, and we have two separate Delphi wrappers (not sure which one is better):
https://github.com/pult/libssh2_delphi
and
https://github.com/dimmaq/delphi-libssh2
SecureBridge from DevArt also support SFTP, comes with full source for the Professional Editon.
I have been using the method to import excel data to my WPF application as mentioned in
Import Excel file into Microsoft SQL Server using C#
and
Reading Excel files from C#
it works great on debug mode but on release mode it dies!
The problem is my client has moved to x64 based machines and the application works fine but just that this piece of code is not working on x64 just because there is no more "Microsoft .Jet.OLEDB.4.0" drivers made available for x64 machines any more.
I dont want to use office interop or provide any dependency for the user to have office installed on the machines.
So any suggestion to avoid this?
Try using Microsoft.Ace.OLEDB.12.0 drivers instead
When we started upgrading all our machines, all my queries using Microsoft.Jet.OLEDB.4.0 stopped working and I had to upgrade them to use Microsoft.Ace.OLEDB.12.0. You shouldn't need to do anything other than change your connection string for it to work.
You could also try using the OpenXML SDK 2.0!
Here's an article that explains reading an excel file using the SDK: http://debugmode.net/2011/10/08/reading-excel-file-in-a-collection-using-open-xml-sdk-2-0/
Getting started and best practices: http://blogs.msdn.com/b/erikaehrli/archive/2009/05/14/open-xml-format-sdk-2-0-getting-started-best-practices.aspx
Hope this helps! ;)
I am using Aspose.cells library. It works pretty good and really easy to work. you can give it a try!
http://www.aspose.com/.net/excel-component.aspx
I want to write an app to test whether a Windows machine is responding correctly to RDP (Remote Desktop) - i.e. to check if the machine not only allows the connection, but is also responding normally, and is not hung or otherwise responding abnormally.
Is there a library or utility that I can use to do this? My searches turned up full RDC clients, but I'm hoping there's something out there at least offers an API for testing. I would most like to use Java or a scripting language to do this, but I'm open to suggestions.
You can find some good answers in this question: Programmatically create and launch and RDP session (without gui)
Because RDP is a constantly evolving proprietary protocol, i'm guessing there isn't some simple open-source code you can take and use. This leaves us with two possible paths to follow:
Use Microsoft RDP ActiveX control (on Windows)
Launch mstsc.exe and send keyboard events to it (also on Windows, using your favorite language)
For the second option, I suggest AutoHotkey. It is perfect for automating windows programs and comes with a powerful library. It also has a strong comunity behind it so you can find lots of useful scripts on the internet. I use it to control winamp (like 'i hate this song! delete it and move to next')(well, technically 'move to the next song and delete the previous' because you can't delete the file while in use but you get the idea). If you choose this path, i can help you with the script.
Found this on Experts Exchange:
use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10, Prompt => '', Port >= 3389);
if($t->open("computer.name.or.ip")) {
print "Connect successful\n";
}
else {
print "Could not connect\n";
}
The idea was to attempt a connection and if it can't connect within 'x' amount of seconds, assume it isn't going to work. Gets a bit more complicated if you're trying to see if a login for a specific user works or not, but this should at least get you started.
NOTE: As pointed out in the comments, the original solution left out the RDP port, so I included that in this...