Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > SMySQL Problems (Cocoa Obj-C)

SMySQL Problems (Cocoa Obj-C)
Thread Tools
Junior Member
Join Date: Jul 2002
Location: Australia
Status: Offline
Reply With Quote
Oct 9, 2002, 10:06 AM
 
Hi all,
I'm building a cocoa program in Objective C and I'm using the SMySQL framework to interact with my mysql server. Though I am having some problems.

This is my database:

Name: Test DB
-------------

Table Name: TestTable

+----------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+------+------+-----+---------+-------+
| TestText | text | YES | | NULL | |
+----------+------+------+-----+---------+-------+

All Values in: TestTable

+----------+
| TestText |
+----------+
| Test |
+----------+

----------------------------

My Cocoa App code for conecting an getting a result:

Code:
- (void)getResult { /* MySQL Connection */ SMySQLConnection *msqlConnection = [[SMySQLConnection alloc] initToHost:@"localhost" withLogin:@"syphor" password:@"syphor" usingPort:3306]; NSDictionary *theDict = [[[NSDictionary alloc] init] autorelease]; SMySQLResult *theResult = [[[SMySQLResult alloc] init] autorelease]; NSArray *theFields = [[[NSArray alloc] init] autorelease]; /* Select the db */ [msqlConnection selectDB:@"Testdb"]; theResult = [msqlConnection queryString:@"select * from TestTable"]; theFields = [theResult fetchFieldsName]; theDict = [theResult fetchRowAsDictionary]; NSLog(@"Result - %@", [theDict objectForKey:[theFields objectAtIndex:0]]); }
------------

The Result I get is:

Code:
Result - <54657374 >
Anyone got any ideas how to get the right result??
     
Professional Poster
Join Date: Sep 1999
Location: Ottawa, ON, Canada
Status: Offline
Reply With Quote
Oct 9, 2002, 11:53 AM
 
I'm relatively new to Cocoa, but I think the problem is in the last line:

NSLog(@"Result - %@", [theDict objectForKey:[theFields objectAtIndex:0]]);

I think your result is a pointer to the object, rather than the value. Maybe try something like

[[theDict objectForKey:[theFields objectAtIndex:0]] description]

Sorry if this doesn't help, it's just a guess. You may also try stepping through with the debugger to make sure the data is actually extracted from the DB.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:54 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2