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!
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 !?
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'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 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.
Hi, i am not sure if this is the correct term, but this is what id like to do:
I have an application that uses a mssql database.
This application can operate in 3 modes.
mode 1) user does not alter, but only read the database
mode 2) user can add rows (one at a time) onto a table in the database
mode 3) user can alter several tables in the database (one person at a time)
question 1) how can i ensure that when a user in in mode 3 that the database will "lock" and all logged in users who operate in mode 2 or mode 3 will not be able to change the database until he finishes?
question 2) how can i ensure that while there are several users in mode 2, that there will be no conflict while they all update the table? my guess here, is that before adding a new row, you make a server query for the table's current unique keys and add the new entry. will this be safe enough though?
Thanks
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 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.
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??
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
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?
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?
One area of question for me about DTOs/BOs is about when to pass/return the DTOs and when to pass/return the BOs.
My gut reaction tells me to always map NHibernate to the DTOs, not BOs, and always pass/return the DTOs. Then whenever I needed to perform business logic, I would convert my DTO into a BO.
The way I would do this is that my BO would have a have a constructor that takes a parameter that is the type of my interface (that defines the required fields/properties) that both my DTO and BO implement as the only argument.
Then I would be able to create my BO by passing it the DTO in the constructor (since both with implement the same interface, they both with have the same properties) and then be able to perform my business logic with that BO. I would then also have a way to convert a BO to a DTO.
However, I have also seen where people seem to only work with BOs and only work with DTOs in the background where to the user, it looks like there are no DTOs.
What benefits/downfalls are there with this architecture vs always using BO's?
Should I always being passing/returning either DTOs or BOs or mix and match (seems like mixing and matching could get confusing)?
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.
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??
Trying for hours to get a request token using Google OAuthGetRequestToken but it always returns "signature_invalid".
For a test I use the oAuth Playground to successfully request the token. Here are the results:
Signature base string
GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_callback%3Dhttp%253A%252F%252Fgooglecodesamples.com%252Foauth_playground%252Findex.php%26oauth_consumer_key%3Dwww.embeddedanalytics.com%26oauth_nonce%3D56aa884162ed21815a0406725c79cf79%26oauth_signature_method%3DRSA-SHA1%26oauth_timestamp%3D1321417095%26oauth_version%3D1.0%26scope%3Dhttps%253A%252F%252Fwww.google.com%252Fanalytics%252Ffeeds%252F
Request/Response
GET /accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fanalytics%2Ffeeds%2F HTTP/1.1
Host: www.google.com
Accept: */*
Authorization: OAuth oauth_version="1.0", oauth_nonce="56aa884162ed21815a0406725c79cf79", oauth_timestamp="1321417095", oauth_consumer_key="www.embeddedanalytics.com", oauth_callback="http%3A%2F%2Fgooglecodesamples.com%2Foauth_playground%2Findex.php", oauth_signature_method="RSA-SHA1", oauth_signature="qRtorIaSFaQdOXW1u6eMQlY9LT2j7ThG5kgkcD6rDcW4MIvzluslFgYRNTuRvnaruraNpItjojtgsrK9deYRKoHBGOlU27SsWy6jECxKczcSECl3cVAcjk7dvbywFMDkgi1ZhTZ5Q%2BFoD60HoVQUYnGUbOO0jPXI48LfkiA5ZN4%3D"
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Date: Wed, 16 Nov 2011 04:18:15 GMT
Expires: Wed, 16 Nov 2011 04:18:15 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Length: 118
Server: GSE
oauth_token=4%2FmO86qZzixayI2NoUc-hewC--D53R&oauth_token_secret=r0PReF9D83w1d6uP0nyQQm9c&oauth_callback_confirmed=true
I am using Fiddler to trace my calls. It returns the Signature base string:
GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_callback%3Dhttp%253A%252F%252Fgooglecodesamples.com%252Foauth_playground%252Findex.php%26oauth_consumer_key%3Dwww.embeddedanalytics.com%26oauth_nonce%3Dl9Jydzjyzt2fJfM3ltY5yrxxYy2uh1U7%26oauth_signature_method%3DRSA-SHA1%26oauth_timestamp%3D1321417107%26oauth_version%3D1.0%26scope%3Dhttps%253A%252F%252Fwww.google.com%252Fanalytics%252Ffeeds%252F
Aside from the oauth_timestamp and oauth_nonce (which should be different), the base string are pretty much identical.
Anyone know what I am doing wrong?
Update 11/20/2011 Thinking it might be something wrong with my RSA-SHA signing, I have since tried HMAC-SHA. It gives the same results. I thought it might be beneficial to include the Fiddler results (I added carriage returns to have it format better).
GET https://www.google.com/accounts/OAuthGetRequestToken?
scope=https%3A%2F%2Fwww.google.com%2Fanalytics%2Ffeeds%2F HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth oauth_version="1.0",
oauth_nonce="7C4C900EAACC9C7B62E399A91B81D8DC",
oauth_timestamp="1321845418",
oauth_consumer_key="www.embeddedanalytics.com",
oauth_signature_method="HMAC-SHA1",
oauth_signature="ows%2BbFTNSR8jVZo53rGBB8%2BfwFM%3D"
Host: www.google.com
Accept: */*
Accept-Encoding: identity
Response
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=UTF-8
Date: Mon, 21 Nov 2011 03:16:57 GMT
Expires: Mon, 21 Nov 2011 03:16:57 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Length: 358
Server: GSE
signature_invalid
base_string:GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken
&oauth_consumer_key%3Dwww.embeddedanalytics.com
%26oauth_nonce%3D7C4C900EAACC9C7B62E399A91B81D8DC
%26oauth_signature_method%3DHMAC-SHA1
%26oauth_timestamp%3D1321845418
%26oauth_version%3D1.0
%26scope%3Dhttps%253A%252F%252Fwww.google.com%252Fanalytics%252Ffeeds%252F
Hi Guys,
I have a stock table and I would like to create a report that will show how often were items ordered.
"stock" table:
item_id | pcs | operation
apples | 100 | order
oranges | 50 | order
apples | -100 | delivery
pears | 100 | order
oranges | -40 | delivery
apples | 50 | order
apples | 50 | delivery
Basically I need to join these two queries together.
A query which prints stock balances:
SELECT stock.item_id, Sum(stock.pcs) AS stock_balance
FROM stock
GROUP BY stock.item_id;
A query which prints sales statistics
SELECT stock.item_id, Sum(stock.pcs) AS pcs_ordered, Count(stock.item_id) AS number_of_orders
FROM stock
GROUP BY stock.item_id, stock.operation
HAVING stock.operation="order";
I think that some sort of JOIN would do the job but I have no idea how to glue queries together.
Desired output:
item_id | stock_balance | pcs_ordered | number_of_orders
apples | 0 | 150 | 2
oranges | 10 | 50 | 1
pears | 100 | 100 | 1
This is just example. Maybe, I will need to add more conditions because there is more columns. Is there a universal technique of combining multiple queries together?
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.
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'm going nuts over what should be a very simple situation. In an ASP.NET MVC 2 app (not that I think this matters), I have an edit action which takes a very small entity and makes a few changes. The key portion (outside of error handling/security) looks like this:
Todo t = Repository.GetTodoByID(todoID);
UpdateModel(t);
Repository.Save();
Todo is the very simple, small entity with the following fields: ID (primary key), FolderID (foreign key), PercentComplete, TodoText, IsDeleted and SaleEffortID (foreign key). Each of these obviously corresponds to a field in the database.
When UpdateModel(t) is called, t does get correctly updated for all fields which have changed.
When Repository.Save() is called, by the time the SQL is written out, FolderID reverts back to its original value. The complete code to Repository.Save():
public void Save()
{
myDataContext.SubmitChanges();
}
myDataContext is an instance of the DataContext class created by the LINQ-to-SQL designer. Nothing custom has been done to this aside from adding some common interfaces to some of the entities.
I've validated that the FolderID is getting lost before the call to Repository.Save() by logging out the generated SQL:
UPDATE [Todo].[TD_TODO]
SET
[TD_PercentComplete] = @p4,
[TD_TodoText] = @p5,
[TD_IsDeleted] = @p6
WHERE
([TD_ID] = @p0) AND
([TD_TDF_ID] = @p1) AND /* Folder ID */
([TD_PercentComplete] = @p2) AND
([TD_TodoText] = @p3) AND
(NOT ([TD_IsDeleted] = 1)) AND
([TD_SE_ID] IS NULL) /* SaleEffort ID */
-- @p0: Input BigInt (Size = -1; Prec = 0; Scale = 0) [5]
-- @p1: Input BigInt (Size = -1; Prec = 0; Scale = 0) [1] /* this SHOULD be 4 and in the update list */
-- @p2: Input TinyInt (Size = -1; Prec = 0; Scale = 0) [90]
-- @p3: Input NVarChar (Size = 4000; Prec = 0; Scale = 0) [changing text]
-- @p4: Input TinyInt (Size = -1; Prec = 0; Scale = 0) [0]
-- @p5: Input NVarChar (Size = 4000; Prec = 0; Scale = 0) [changing text foo]
-- @p6: Input Bit (Size = -1; Prec = 0; Scale = 0) [True]
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 4.0.30319.1
So somewhere between UpdateModel(t) (where I've validated in the debugger that FolderID updated) and the output of this SQL, the FolderID reverts. The other fields all save. (Well, OK, I haven't validated SaleEffortID yet, because that subsystem isn't really ready yet, but everything else saves.)
I've exhausted my own means of research on this: Does anyone know of conditions which would cause a partial entity reset (EG, something to do with long foreign keys?), and/or how to work around this?
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?