[Mysql-cocoa-users] Getting crazy on this
Brought to you by:
sergecohen
|
From: Zakaria A. <zar...@gm...> - 2005-03-02 12:18:21
|
Hi everyone,
First of all I like to apologize for my poor English.
Here's the problem.
I wrote a Cocoa program for my enterprise. One of the functions is to
connect to a MySql database.
So I downloaded SMySql on my Mac , put the SMySql_static framework
into /Library/FrameWorks
Then I wrote a simple test connection.
After
#import <SMySql_static/SMySql_static.h>
//the usual class header
-(IBAction):connect_to_db:(id)sender;
//.m file
//lots of stuff ommited
-(IBAction)connect_to_db:(id)sender
{
MCPConnection *theConnec = [MCPConnection alloc];
MCPResult *theRes;
NSDictionary *theDict;
NSArray *theColNames;
int i,j;
theConnec = [theConnec initToHost:@"10.0.0.165"
withLogin:@"cde27" password:@"tryToGuess" usingPort:3306];
[theConnec selectDB:@"CDE"];
theRes = [theConnec queryString:@"SELECT * FROM tblPersonelInfoSociete"];
if([theConnec isConnected])
NSLog([theConnec serverInfo]);
else
{ NSBeginAlertSheet(@"Connection Error",
@"Ok",
@"",@"",
window,self,NULL,NULL,NULL,@"Unable to connect to 10.0.0.165");
return; } //show the sheet exit the procedure
theColNames = [theRes fetchFieldsName];
i = 0;
NSLog(@"Im here: the dict is %@ and Colnames are %@", theDict,
theColNames);
while ( theDict = [theRes fetchRowAsDictionary]){
NSLog(@"Row : d\n", i);
for(j=0; j<[theColNames count]; j++){
NSLog(@" Field: %@, containt : %@\n", [theColNames
objectAtIndex:j],
[theDict objectForKey:[theColNames objectAtIndex:j]]);
} //end of for loop
i++;
} //end of while
}
The example comes from the SMySql website
It compiles perfectly but it won't connect. I always receive the alert
sheet unable to connect
But on CocoaMysql I can connect to db without any problem
Can someone help me, did I miss something.
THANKS ALOT
|