Can somebody write me a code, how to view data from tables in c# (using select statement)?
I tried it myself and posted the code here, but i didn't get it right.
Please help!
Hi all,
I am trying to use AVAudioPlayer to play some sounds in quick succession. When I invoke the sound-playing function less frequently so that the sounds play fully before the function is invoked again, the application runs fine. But if I invoke the function quickly in rapid succession (so that sounds are played while the previous sounds are still being played), the app eventually crashes after ~20 calls to the function, with the message "EXC_BAD_ACCESS". Here is code from the function:
NSString *nsWavPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:wavFileName];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:nsWavPath] error:NULL];
theAudio.delegate = self;
[theAudio play];
As mentioned in another thread, I implemented the following delegate function:
- (void) audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
if(!flag)
NSLog(@"audio did NOT finish successfully\n");
[player release];
}
But the app still crashes after around ~20 rapid calls to the function. Any idea what I'm doing wrong?
Sorry, this may be a noob question but I'm working with CoreLocation and this has be stumped.
I'm looking up the currentLocation using a singleton that was recommended on this site and when I get the currentLocation object, it returns true to a not nil check. However, when I try to print out its description, it throws EXC_BAD_ACCESS.
//WORKS Current location 8.6602e-290
NSLog(@"Current location %g",currLoc);
//DOESN'T WORK
NSLog(@"Current location %@",[currLoc description]);
//DOESN'T WORK - Is this causing the description to fail as well?
NSLog(@"Current location %g",currLoc.coordinate.latitude);
Why am I able to see something on the first one but not the others? BTW, this is being run on a 3.1.2 simulator Thanks.
I have enabled NSZombie's and I am getting the following message in my console when I am running my application:
*** -[UIViewAnimationState release]: message sent to deallocated instance 0xf96d7e0
Here is the method that is performing the animation
-(void)loadAvatar:(STObject*)st
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
avatar.alpha = 0;
avatar.frame = avatarRectSmall;
avatar.image = [ImageCache getMemoryCachedImageAtUrl:st.avatar_url];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.50];
avatar.frame = avatarRectNormal;
[avatar setAlpha:1];
[UIView commitAnimations];
[pool release];
pool = nil;
}
I don't always get a crash, only sometimes. I'm wondering what is getting released?
I have a garbage collected Cocoa application built on 10.5 frameworks. In an NSOperation In a loop I am quickly creating hundreds of NSManagedObjects. Frequently the creation of those NSManagedObejcts will crash with a exc_bad_access error.
for (offsetCount; offsetCount < [parsedData count]; offsetCount++) {
NSManagedObject *child = [NSEntityDescription insertNewObjectForEntityForName:@"Thread" inManagedObjectContext:[self moc]];
Thumbnail *thumb = [Thumbnail insertInManagedObjectContext:[self moc]];
Image *image = [Image insertInManagedObjectContext:[self moc]];
...
}
Thumbnail and Image are both subclasses of NSManagedObject generated with mogenerator. insertInManagedObjectContext: looks like
NSParameterAssert(moc_);
return [NSEntityDescription insertNewObjectForEntityForName:@"Thumbnail" inManagedObjectContext:moc_];
NSParameterAssert(moc_);
return [NSEntityDescription insertNewObjectForEntityForName:@"Image" inManagedObjectContext:moc_];
The NSManagedObjectContext returned by [self moc] is created for the NSOperation with
NSPersistentStoreCoordinator *coord = [(MyApp_AppDelegate *)[[NSApplication sharedApplication] delegate] persistentStoreCoordinator];
self.moc = [[NSManagedObjectContext alloc] init];
[self.moc setPersistentStoreCoordinator:coord];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contextDidSave:)
name:NSManagedObjectContextDidSaveNotification
object:self.moc];
[self.moc setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy];
[self.moc setUndoManager:nil];
[self.moc setRetainsRegisteredObjects:YES];
moc is defined as (nonatomic, retain) and synthesized. As far as I can tell it, the persistent store and my appDelegate have no reason to be and are not being garbage collected.
The stack trace looks like
Thread 2 Crashed: Dispatch queue: com.apple.root.default-priority
0 libauto.dylib 0x00007fff82d63600 auto_zone_root_write_barrier + 688
1 libobjc.A.dylib 0x00007fff826f963b objc_assign_strongCast_gc + 59
2 com.apple.CoreFoundation 0x00007fff88677068 __CFBasicHashAddValue + 504
3 com.apple.CoreFoundation 0x00007fff88676d2f CFBasicHashAddValue + 191
4 com.apple.CoreData 0x00007fff82bdee5e -[NSManagedObjectContext(_NSInternalAdditions) _insertObjectWithGlobalID:globalID:] + 190
5 com.apple.CoreData 0x00007fff82bded24 -[NSManagedObjectContext insertObject:] + 148
6 com.apple.CoreData 0x00007fff82bbd75c -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 716
7 com.apple.CoreData 0x00007fff82bdf075 +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 101
8 com.yourcompany.MyApp 0x000000010002c7a7 +[_Thumbnail insertInManagedObjectContext:] + 256 (_Thumbnail.m:14)
9 com.yourcompany.MyApp 0x000000010002672d -[ThreadParse main] + 10345 (B4ChanThreadParse.m:174)
10 com.apple.Foundation 0x00007fff85ee807e -[__NSOperationInternal start] + 698
11 com.apple.Foundation 0x00007fff85ee7d23 ____startOperations_block_invoke_2 + 99
12 libSystem.B.dylib 0x00007fff812bece8 _dispatch_call_block_and_release + 15
13 libSystem.B.dylib 0x00007fff8129d279 _dispatch_worker_thread2 + 231
14 libSystem.B.dylib 0x00007fff8129cbb8 _pthread_wqthread + 353
15 libSystem.B.dylib 0x00007fff8129ca55 start_wqthread + 13
My app is crashing in other places with exc_bad_access but this is code that it happens most with. All of the stack traces look similar and have something to do with CFHash.
Any help would be appreciated.
I am trying to connect to my webserver via ssh but I can't. When I insert the password then the terminal is blocked. This is what I see:
# ssh [email protected][email protected]'s password:
Why ?
In iptables there are no rules.
Please help :(
in .h file I write
-(IBAction)openShuffleForm;
and .m
-(IBAction)openShuffleForm{
NSLog(@"XXXXXXX");
}
and connect with even touch up inside
but when I run my program it error show this message
-[UITouchData openShuffleForm]: unrecognized selector sent to instance 0x391cc20
** what happen I don't know why !?
i have two computer
PC1 and PC2
in PC1 i have a .Net C# dll file that provides operations on sql server database.
my question is - "how can i use this dll file on PC2 through VBScript within Outlook 2003".
I tried this same task on PC1 and i succeeded using the
CreateObject("dllfilename.classname") method of VBScript within outlook 2003.
but now i want to use that dll file on PC2.
is there any efficient way by which i can use that dll on PC2 without having to copy dll on PC2.
Are the following equivalent?
private static boolean readAllFiles = false,readAllDirs = false;
private static boolean readAllFiles = false;
private static boolean readAllDirs = false;
And if so, do they still have the same modifiers with different values?
private static boolean readAllFiles = false,readAllDirs = true;
I am trying to assign salespeople (rsSalespeople) to customers (rsCustomers) in a round-robin fashion in the following manner:
Navigate to first Customer, assign the first SalesPerson to the Customer.
Move to Next Customer. If rsSalesPersons is not at EOF, move to Next SalesPerson; if rsSalesPersons is at EOF, MoveFirst to loop back to the first SalesPerson. Assign this (current) SalesPerson to the (current) Customer.
Repeat step 2 until rsCustomers is at EOF (EOF = True, i.e. End-Of-Recordset).
It's been awhile since I dealt with VBA, so I'm a bit rusty, but here is what I have come up with, so far:
Private Sub Command31_Click()
'On Error GoTo ErrHandler
Dim intCustomer As Integer
Dim intSalesperson As Integer
Dim rsCustomers As DAO.Recordset
Dim rsSalespeople As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT CustomerID, SalespersonID FROM Customers WHERE SalespersonID Is Null"
Set rsCustomers = CurrentDb.OpenRecordset(strSQL)
strSQL = "SELECT SalespersonID FROM Salespeople"
Set rsSalespeople = CurrentDb.OpenRecordset(strSQL)
rsCustomers.MoveFirst
rsSalespeople.MoveFirst
Do While Not rsCustomers.EOF
intCustomers = rsCustomers!CustomerID
intSalesperson = rsSalespeople!SalespersonID
strSQL = "UPDATE Customers SET SalespersonID = " & intSalesperson & " WHERE CustomerID = " & intCustomer
DoCmd.RunSQL (strSQL)
rsCustomers.MoveNext
If Not rsSalespeople.EOF Then
rsSalespeople.MoveNext
Else
rsSalespeople.MoveFirst
End If
Loop
ExitHandler:
Set rsCustomers = Nothing
Set rsSalespeople = Nothing
Exit Sub
ErrHandler:
MsgBox (Err.Description)
Resume ExitHandler
End Sub
My tables are defined like so:
Customers
--CustomerID
--Name
--SalespersonID
Salespeople
--SalespersonID
--Name
With ten customers and 5 salespeople, my intended result would like like:
CustomerID--Name--SalespersonID
1---A---1
2---B---2
3---C---3
4---D---4
5---E---5
6---F---1
7---G---2
8---H---3
9---I---4
10---J---5
The above code works for the intitial loop through the Salespeople recordset, but errors out when the end of the recordset is found. Regardless of the EOF, it appears it still tries to execute the rsSalespeople.MoveFirst command.
Am I not checking for the rsSalespeople.EOF properly? Any ideas to get this code to work?
I have been banging my head against the wall for a couple days and need some help. I have a feeling that I am doing something really silly here, but I cannot find the issue. This is the controller for a table view. I put the SQL in line to simplify it as part of the troubleshooting of this error. Normally, it would be in an accessor method in a model class.
It gets through the SQL read just fine. Finds the two objects, loads them into the todaysWorkout array and then builds the cells for the table view. The table view actually comes up on the scree and then it throws the EXC_BAD_ACCESS.
I ran instruments and it shows the following:
0 CFString Malloc 1 00:03.765 0x3946470 176 Foundation -[NSPlaceholderString initWithFormat:locale:arguments:]
1 CFString Autorelease 00:03.765 0x3946470 0 Foundation NSRecordAllocationEvent
2 CFString CFRelease 0 00:03.767 0x3946470 0 Bring It -[WorkoutViewController viewDidLoad]
3 CFString Zombie -1 00:03.917 0x3946470 0 Foundation NSPopAutoreleasePool
Here is the source code for the controller. I left it all in there just in case there is something extraneous causing the problem. I sincerely appreciate any help I can get:
#import "WorkoutViewController.h"
#import "MoveListViewController.h"
#import "Profile.h"
static sqlite3 *database = nil;
@implementation WorkoutViewController
@synthesize todaysWorkouts;
@synthesize woNoteCell;
@synthesize bi;
//@synthesize woSwitchCell;
- (void)viewDidLoad {
[super viewDidLoad];
bi = [[BIUtility alloc] init];
todaysWorkouts = [[NSMutableArray alloc] init];
NSString *query;
sqlite3_stmt *statement;
//open the database
if (sqlite3_open([[BIUtility getDBPath] UTF8String], &database) != SQLITE_OK) {
sqlite3_close(database);
NSAssert(0, @"Failed to opendatabase");
}
query = [NSString stringWithFormat:@"SELECT IWORKOUT.WOINSTANCEID, IWORKOUT.WORKOUTID, CWORKOUTS.WORKOUTNAME FROM CWORKOUTS JOIN IWORKOUT ON IWORKOUT.WORKOUTID = CWORKOUTS.WORKOUTID AND DATE = '%@'", [BIUtility todayDateString]];
if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
Workout *wo = [[Workout alloc] init];
wo.woInstanceID = sqlite3_column_int(statement, 0);
wo.workoutID = sqlite3_column_int(statement, 1);
wo.workoutName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)];
[todaysWorkouts addObject:wo];
[wo release];
}
sqlite3_finalize(statement);
}
if(database) sqlite3_close(database);
[query release];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//todaysWorkouts = [BIUtility todaysScheduledWorkouts];
static NSString *noteCellIdentifier = @"NoteCellIdentifier";
UITableViewCell *cell;
if (indexPath.section < ([todaysWorkouts count])) {
cell = [tableView dequeueReusableCellWithIdentifier:@"OtherCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier: @"OtherCell"] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
}
if (indexPath.row == 0) {
Workout *wo = [todaysWorkouts objectAtIndex:indexPath.section];
[cell.textLabel setText:wo.workoutName];
} else {
[cell.textLabel setText:@"Completed?"];
[cell.textLabel setFont:[UIFont fontWithName:@"Arial" size:15]];
[cell.textLabel setTextColor:[UIColor blueColor]];
}
} else {
cell = (NoteCell *)[tableView dequeueReusableCellWithIdentifier:noteCellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NoteCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
}
return cell;
//[cell release];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
if (indexPath.section < ([todaysWorkouts count]) && (row == 0)) {
MoveListViewController *moveListController = [[MoveListViewController alloc] initWithStyle:UITableViewStylePlain];
moveListController.workoutID = [[todaysWorkouts objectAtIndex:indexPath.section] workoutID];
moveListController.workoutName = [[todaysWorkouts objectAtIndex:indexPath.section] workoutName];
moveListController.woInstanceID = [[todaysWorkouts objectAtIndex:indexPath.section] woInstanceID];
NSLog(@"Workout Selected: %@", [[todaysWorkouts objectAtIndex:indexPath.section] workoutName]);
Bring_ItAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.workoutNavController pushViewController:moveListController animated:YES];
} else {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (indexPath.section < ([todaysWorkouts count]) && (row == 1)) {
if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger h = 35;
return h;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return ([todaysWorkouts count] + 1);
//return ([todaysWorkouts count]);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section < ([todaysWorkouts count])) {
return 2;
} else {
return 1;
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section < ([todaysWorkouts count])) {
return @"Workout";
} else {
return @"How Was Your Workout?";
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[todaysWorkouts release];
[bi release];
[super dealloc];
}
@end
I'm getting a formatting problem if I use more than 10 UNION ALL statements in my VBA Code.
If I use 10 or less everything works great.
What I'm trying to do is combine 12 worksheets (Excel 2007).
I have a numerical column called SC that turns into string and date if I have more than 10 UNION ALL. If I try to use ROUND with more than 10 UNION ALL my last selection will change all the records by one unit.
I'm using Microsoft.ACE.OLEDB.12.0 as my provider and my connection string has worked for several things in my code so far.
Is there any limit for UNION ALL statements when using OLEDB?
Here is my code.
Dim StrOr As String
Dim i As Variant
Dim Cnt As ADODB.Connection
Dim Rs As ADODB.Recordset
For i = 1 To 12
StrOr = StrOr & " " & "SELECT SC FROM [" & MonthName(i, True) & "$" & "] UNION ALL"
Next
StrOr = Left(StrOr, Len(StrOr) - 9) & ";"
Call GetADOCnt
Call ADORs
I have a method in rails that is doing something like this:
a = Foo.new("bar")
a.save
b = Foo.new("baz")
b.save
...
x = Foo.new("123", :parent_id => a.id)
x.save
...
z = Foo.new("zxy", :parent_id => b.id)
z.save
The problem is this takes longer and longer the more entities I add. I suspect this is because it has to hit the database for every record. Since they are nested, I know I can't save the children before the parents are saved, but I would like to save all of the parents at once, and then all of the children. It would be nice to do something like:
a = Foo.new("bar")
b = Foo.new("baz")
...
saveall(a,b,...)
x = Foo.new("123", :parent_id => a.id)
...
z = Foo.new("zxy", :parent_id => b.id)
saveall(x,...,z)
That would do it all in only two database hits. Is there an easy way to do this in rails, or am I stuck doing it one at a time?
hi
what i am trying to do is get all the collums of a table (the table can be empty)
example of what i did before:
SELECT COLUMN_NAME FROM
INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'aTable'
AND table_schema = 'theDatabase'
it works perfectly on localhost however on my provider it gives:
#1142 - SELECT command denied to user 'username'@'localhost' for table 'COLUMNS'
is there an alternative that doesn't use the INFORMATION_SCHEMA??
I am using htaccess to redirect to url with page description. For example
RewriteRule ^Flash$ /index.php?section=flash [L,NC]
By using this code when i hot domain.com/Flash it redirects me to www.domain.com/index.php? section=flash. This works fine. But now what i want to have two more site with the same htaccess file.
So can anyone help me in redirecting the url with same htaccess for multiple site. Can i find the base url and redirect depending on that??
Hi everyone. I'm new to iPhone development and have a question I hope someone can help me with.
I have a programmer working on an iPhone app for me and when I run the app in the simulator, it works great. But when I try to run it on my actual iPhone, I get a EXC_BAD_ACCESS error and the app locks up.
Looking at the debugger, it's referencing the following code in my MainController as the problem:
-(void)loadAddressBook{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
addressBookLoaded=1;
[AddressbookRecord readAllContactTable:[self getDBPath]];
ABAddressBookRef addressBook = ABAddressBookCreate();
for(NSUInteger i=1;i<=ABAddressBookGetPersonCount(addressBook);i++) {
ABRecordRef myPerson =ABAddressBookGetPersonWithRecordID (addressBook,(ABRecordID)(i));
NSString *name = (NSString*)ABRecordCopyCompositeName(myPerson);
//save in database
AddressbookRecord *addObj = [[AddressbookRecord alloc] initWithPrimaryKey:0];
addObj.ClientName=name;
[addObj addNewContactEntry];
}
addressBookLoaded=2;
[pool release];
}
More specifically, it points to this specific line as the problem:
NSString *name =(NSString*)ABRecordCopyCompositeName(myPerson);
My programmer can't seem to figure out what the problem is since he can't replicate it on his end. Does anyone have any ideas what would cause this problem???
Thanks!
so I have a combo box that I want to pop up when somebody wants to search by year.
It will allow them to see in that combo box only results that happened in a certain year.
so far I have something like
SELECT DISTINCT Database_New.ASEC
FROM Database_New
WHERE (((Database_New.Date) >= DateValue('01/01/2001')
AND (((Database_New.Date) <= DateValue('12/031/2001')));
or
SELECT DISTINCT Database_New.ASEC
FROM Database_New
WHERE (((Database_New.Date) >= BETWEEN DateValue('01/01/2001')
AND DateValue('12/31/2001’)));
as you can see, the kicker is that I am already sorting the thing with SELECT DISTINCT under the ASEC field. But I want to filter it one more by year so a whole bunch of ASEC values that didnt happen in that year (and there are quite a few that happen rarely, or would onyl be associeted with one year) do not pop up as avalible.
so far I get an error like
"Syntax error in query expression '(((Database_New.Date) = DateValue('01/01/2001')
AND (((Database_New.Date) <= DateValue('12/031/2001')))'
and I am a VBA person, not quite as good at debuggin SQL.
Is it something easy?
or will it simply not work the way I have it set up.
What is an easy way to list the foreign key contraints in an MDB?
Is there a system table that can be queried in order to list this information?
Specifically, I need to know whether any foreign key contraints exist in the MDB.
OK, so say I have a table with 500K rows, then I ad-hoc query with unsupported indexing which requires a full table scan. I would like to immediately view the first rows returned while the full table scan continues. Then I want to scroll thru the next results. In the meantime, I would like to display the progress of the table scan, example: "SEARCHING.. FOUND 23 OF 500,000 ROWS SO FAR". If I scroll too far ahead, I want to display a message like: "REACHED LAST ROW IN LOOK-AHEAD BUFFER.. QUERY HAS NOT COMPLETED".. Can this be done? Maybe like: spawn/exec, declare scroll cursor, open, fetch, etc.?
I have a mysqld server running on a windows 7 machine. how to allow a windows vista machine to connect to this server. I need to set some permissions using
grant all permissions to username@ip
but what should be the username and ip. i am not sure with windows.
I'd like to flash the taskbar (as described here for example), but I can't P/Invoke FlashWindowEx (or anything else, for that matter) in the security context my application is running in.
Is there another way to get the taskbar to flash? If not, what are my options for getting the user's attention?
I am using wamp and creating a Joomla template with changeable parameters.
initially the message is
The parameter file \templates\ssc_2010\params.ini is
writable!
once I make changes everything works as expected, except now i get the message:
The parameter file \templates\ssc_2010\params.ini is
unwritable!
One solution is to brows to the directory, right click the file, select properties, and uncheck read-only. Again the file is writable but once I modify the parameters again it becomes read only again. I'm quite lazy and would like to prevent this from happening again, I've notice this happening in past projects, but now I have to work a lot with parameters so it becomes quite boring doing manual labor like that :P