适用于 iOS 的原生 Microsoft SQL Server 客户端。围绕开源 FreeTDS 库的 Objective-C 封装。
#import "SQLClient.h" SQLClient* client = [SQLClient sharedInstance]; client.delegate = self; [client connect:@"server:port" username:@"user" password:@"pass" database:@"db" completion:^(BOOL success) { if (success) { [client execute:@"SELECT * FROM Users" completion:^(NSArray* results) { for (NSArray* table in results) for (NSDictionary* row in table) for (NSString* column in row) NSLog(@"%@=%@", column, row[column]); [client disconnect]; }]; } }]; //Required - (void)error:(NSString*)error code:(int)code severity:(int)severity { NSLog(@"Error #%d: %@ (Severity %d)", code, error, severity); }
打开位于 SQLClient 文件夹中的 Xcode 项目。
SQLClient:iOS 的原生 Microsoft SQL Server 库
FreeTDS:http://www.freetds.org
FreeTDS-iOS:https://github.com/patchhf/FreeTDS-iOS
C 语言 FreeTDS 示例代码:http://freetds.schemamania.org/userguide/samplecode.htm