[Mysql-cocoa-users] Re: Mysql-cocoa-users digest, Vol 1 #87 - 1 msg
Brought to you by:
sergecohen
|
From: Lorenz T. <lo...@te...> - 2003-11-10 12:55:31
|
Hi Chris,
Try something like the following:
1. Add the compiled framework to your project.
2. If you want the framework be included in your executable, add a copy
files build phase for the framework.
3. Import the framework header file in your class header file:
#import <SMySQL/SMySQL.h>
4. Put code similar to the following in your awakeFromNib method (I'm
still working with an old version of the framework, but the following
code should work in v2):
// set up the mysql connection
MCPConnection *mySQLConnection;
mySQLConnection = [[MCPConnection alloc] initToHost:@"yourHost"
withLogin:@"yourLogin"
password:@"yourPassword"
usingPort:@"theMySQLPort"];
// select the db
[mySQLConnection selectDB:@"yourDB"];
// perform the query
NSArray *theResult;
theResult = [mySQLConnection getAllRowsFromQuery:@"SELECT * FROM
yourTable" asType:MCPTypeArray];
// put the result in your textfield, so e.g. ...
int i;
NSMutableString *theString = [NSMutableString string];
for ( i = 0 ; i < [theResult count] ; i++ ) {
[theString appendString:[[theResult objectAtIndex:i]
componentsJoinedByString:@"\t"]];
[theString appendString:@"\n"];
}
[yourTextField setStringValue:theString];
Hope that helps. Feel free to send me an email when you have more
questions!
- Lorenz
On Monday, Nov 10, 2003, at 05:13 Europe/Rome,
mys...@li... wrote:
> To: mys...@li...
> From: chris <ch...@th...>
> Date: Sun, 9 Nov 2003 11:16:44 -0800
> Subject: [Mysql-cocoa-users] Getting out the starting gate
>
> I'm trying to get even the most basic returns from MySQL and having
> difficulty getting results. How would I say at awakeFromNib to put
> into my text field the contents of a table?
>
> --chris
|