Sql连接多个表返回两列的产品(Sql Joins on multiple table returning product of two columns)
我试图在asp.net中生成一个sql server数据库的报告,我得到一些列的结果作为两列的产品。 这是代码
comm.CommandText = "SELECT Count(Courses.CourseID) AS CourseCount, Count(Students.StudentID) AS StudentCount, Schools.Name, Schools.StartDate, Schools.SchoolFees " + "FROM Schools" + "LEFT JOIN Courses ON (Schools.SchoolID = Courses.SchoolID)" + "LEFT JOIN Students ON (Schools.SchoolID = Students.SchoolID) " + "WHERE Schools.Active = 1 " + "GROUP BY Schools.Name, Schools.StartDate, Schools.SchoolFees";
当我运行代码时,显示结果,但“CourseCount”和“StudentCount”的列显示的值是每个列的乘积。 “CourseCount”通常为288,“StudentCount”为38,但是当我运行代码时,“CourseCount”和“StudentCount”都显示10944,即38 x 288。
无论如何,我可以让他们显示正确的值?
I am trying to generate a report on a sql server database in asp.net and I am getting the results of some columns as a product of two columns. Here is the code
comm.CommandText = "SELECT Count(Courses.CourseID) AS CourseCount, Count(Students.StudentID) AS StudentCount, Schools.Name, Schools.StartDate, Schools.SchoolFees " + "FROM Schools" + "LEFT JOIN Courses ON (Schools.SchoolID = Courses.SchoolID)" + "LEFT JOIN Students ON (Schools.SchoolID = Students.SchoolID) " + "WHERE Schools.Active = 1 " + "GROUP BY Schools.Name, Schools.StartDate, Schools.SchoolFees";
When I run the code, the result displays, but the columns for "CourseCount" and "StudentCount" display a value that is a product of each individual column. "CourseCount" is normally 288 and "StudentCount" is 38 but when I run the code, both "CourseCount" and "StudentCount" display 10944 which is 38 x 288.
Anyway I can make them display the correct values?
原文:https://stackoverflow.com/questions/37052141
最满意答案
以下是上面的区别:
barTintColor:应用于导航栏背景的色调颜色。
backgroundColor:更改navigationBar的背景颜色
tintColor:应用于导航项目和条形按钮项目的色调颜色。
UITextAttributeTextColor:文本属性字典中文本颜色的关键字。相应的值是UIColor的一个实例。
Available in iOS 5.0 and later.Deprecated in iOS 7.0.
这是一个easy fix
。 只需将UITextAttributeTextColor to NSForegroundColorAttributeName
更改UITextAttributeTextColor to NSForegroundColorAttributeName
以下是更多详细信息: https : //developer.apple.com/library/ios/documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html
Here are the difference between above :
barTintColor : The tint color to apply to the navigation bar background.
backgroundColor : change the background color of navigationBar
tintColor : The tint color to apply to the navigation items and bar button items.
UITextAttributeTextColor : Key to the text color in a text attributes dictionary.The corresponding value is an instance of UIColor.
Available in iOS 5.0 and later.Deprecated in iOS 7.0.
It’s aneasy fix
. Just changeUITextAttributeTextColor to NSForegroundColorAttributeName
Here is the more details : https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html
相关问答
更多-
为什么tintColor不能在iOS7上的导航栏或工具栏上工作(Why tintColor doesn't work on navigation bar or toolbar on iOS7)[2024-01-21]
发生这种情况是因为Apple假定我们不会提供多个视图控制器,并将背景和所有条形按钮项目(不确定原因)调暗为默认行为,以便将焦点放在最前面的视图上。 要解决此问题,您只需要在DidFinishLaunchingWithOptions的应用程序窗口中强制tintAdjustmentMode为Normal。 self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; This happens because Apple assumes tha ... -
以下是上面的区别: barTintColor:应用于导航栏背景的色调颜色。 backgroundColor:更改navigationBar的背景颜色 tintColor:应用于导航项目和条形按钮项目的色调颜色。 UITextAttributeTextColor:文本属性字典中文本颜色的关键字。相应的值是UIColor的一个实例。 Available in iOS 5.0 and later.Deprecated in iOS 7.0. 这是一个easy fix 。 只需将UITextAttributeTex ...
-
你可以在搜索器中设置图像。 它将适用于搜索栏。 [[UISearchBar appearance] setBackgroundImage:[UIImage imageNamed:@"red"]]; you can set image in searcher. It will work for searchbar. [[UISearchBar appearance] setBackgroundImage:[UIImage imageNamed:@"red"]];
-
UISearchBar的默认barTintColor和backgroundColor(Default barTintColor and backgroundColor for UISearchBar)[2023-01-16]
鉴于没有人回答,这篇文章在相关谷歌搜索结果中很高,我想给出最终为我修复的答案。 简单地将颜色设置为nil可以使它们使用默认值。 Given nobody has answered and this post is high up in relevant google search results, I'd like to give the answer that finally fixed it for me. Simply setting the colour to nil works in making ... -
快速的barTintColor(barTintColor in swift)[2022-05-24]
你可以创建你自己的自定义十六进制扩展来很容易地完成这个。 例如,这样的事情可能会起作用: extension UIColor { convenience init(hex: Int) { let r = hex / 0x10000 let g = (hex - r*0x10000) / 0x100 let b = hex - r*0x10000 - g*0x100 self.init(red: CGFl ... -
你忘了%,应该是 self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.008 green:0.22 blue:0.514 alpha:1.0]; 编辑,关于如何使statusBar变白 在info.plist文件中将此键设置为NO View controller-based status ...
-
UISegmentedContol:反转tintColor和backgroundColor(UISegmentedContol: reverse tintColor and backgroundColor)[2023-07-11]
您可以使用UIApplication.sharedApplication().delegate?.window??.tintColor来设置应用程序的所有控件使用的全局色调颜色。 您可以使用UISegmentedControl.appearance().tintColor为应用程序中的所有分段控件设置自定义色调颜色。 您可以使用UISegmentedControl.tintColor为特定的分段控件设置自定义色调颜色。 要切换应用程序中所有分段控件的背景和色调颜色: UISegmentedControl.a ... -
在viewDidLoad尝试这个: let customSegmentedControl = UISegmentedControl (items: ["one","two","three"]) 并将tintColor设置为它。 customSegmentedControl.tintColor = UIColor.red Try this inside of viewDidLoad: let customSegmentedControl = UISegmentedControl (items: ["one ...
-
最简单的解决方案: func scrollViewDidScroll(scrollView: UIScrollView) { if (scrollView.contentOffset.y > 0) { self.navigationController?.navigationBar.backgroundColor = UIColor.whiteColor() self.navigationController?.navigationBar.ti ...
-
您必须将rgb颜色值除以255并转换为float,如下所示: self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:33.0f/255.0f green:50.0f/255.0f blue:86.0f/255.0f alpha:1.0f]; 通常我声明以下宏: #define Color(r,g,b,a) [UIColor colorWithRed:(r/(float)255) green:(g/(floa ...