我在一些插入T-SQL查询中看到了前缀N. 许多人N
在将值插入表中之前已经使用过.
我搜索过,但是我无法理解N
在将任何字符串插入表格之前包括之前的目的是什么.
INSERT INTO Personnel.Employees
VALUES(N'29730', N'Philippe', N'Horsford', 20.05, 1),
Run Code Online (Sandbox Code Playgroud) 我在C#中搜索过静态变量,但我仍然没有得到它的用途.另外,如果我尝试在方法中声明变量,它将不会授予我执行此操作的权限.为什么?
我看过一些关于静态变量的例子.我已经看到我们不需要创建类的实例来访问变量,但这还不足以理解它的用途以及何时使用它.
第二件事
class Book
{
public static int myInt = 0;
}
public class Exercise
{
static void Main()
{
Book book = new Book();
Console.WriteLine(book.myInt); // Shows error. Why does it show me error?
// Can't I access the static variable
// by making the instance of a class?
Console.ReadKey();
}
}
Run Code Online (Sandbox Code Playgroud) 我开发了一个窗口应用程序,我也创建了一个服务.我在窗口应用程序中使用编码启动服务,但是我收到的错误就是无法在计算机上打开窗口服务'.'
我使用下面的代码.
ServiceController controller = new ServiceController("SeoMozScheduleService");
if (controller.Status == ServiceControllerStatus.Stopped)
{
controller.Start();
}
Run Code Online (Sandbox Code Playgroud)
如果我右键单击应用程序并单击以管理员身份运行,它对我来说工作正常...
我刚刚开始使用Json学习Json并将数据绑定到Gridview,但我无法理解contentType和dataType和数据是什么?
我使用了以下代码............
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Gridview.aspx/BindDatatable",
data: "{}",
dataType: "json",
success: function (data) {
for (var i = 0; i < data.d.length; i++) {
$("#gvDetails").append("<tr><td>" + data.d[i].OfficeName + "</td><td>" + data.d[i].City + "</td><td>" + data.d[i].Country + "</td></tr>");
}
},
error: function (result) {
alert("Error");
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我试过但无法得到正确的解决方案.我想要一个SQL查询,列出当前年份的所有周末日期.
我试过这个SQL查询:
WITH hier(num, lvl) AS (
SELECT 0, 1
UNION ALL
SELECT 100, 1
UNION ALL
SELECT num + 1, lvl + 1
FROM hier
WHERE lvl < 100
)
SELECT lvl [Week],
convert(date,DATEADD(dw, -DATEPART(dw, DATEADD(wk,DATEDIFF(wk,0,'12/31/'+convert(nvarchar,YEAR(getdate()))), 0)+6 ),
DATEADD(wk, DATEDIFF(wk,0,'12/31/'+convert(nvarchar,YEAR(getdate()))), 0)+6 ) - num * 7,101) [End Date]
FROM hier a
where num < 52
ORDER BY [End Date] asc
Run Code Online (Sandbox Code Playgroud)
它的输出是这样的:
Week End date
52 2012-01-14
51 2012-01-21
50 2012-01-28
49 2012-02-04
Run Code Online (Sandbox Code Playgroud)
我希望日期从头开始 - 所以,上面缺少一个周末,这是2012-07-01
.此外,我希望周数显示1, 2, …
我需要在注册页面上使用https,在其他地方使用http.我在global.asax中编写了以下代码:
protected void Application_BeginRequest(object sender, EventArgs e)
{
var currentUrl = System.Web.HttpContext.Current.Request.Url;
if (currentUrl.AbsoluteUri.Contains("Registration"))
{
if (!currentUrl.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.CurrentCultureIgnoreCase))
{
//build the secure uri
var secureUrlBuilder = new UriBuilder(currentUrl);
secureUrlBuilder.Scheme = Uri.UriSchemeHttps;
//use the default port.
secureUrlBuilder.Port = string.IsNullOrEmpty(ConfigurationManager.AppSettings["HttpsPort"].ToString()) ? 443 : Convert.ToInt32(ConfigurationManager.AppSettings["HttpsPort"].ToString());
//redirect and end the response.
System.Web.HttpContext.Current.Response.Redirect(secureUrlBuilder.Uri.ToString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
这对于访问注册页面工作正常,但是当我访问其他页面时,该方案不会切换回http.
我有这样的代码
protected void rptCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRow dr = ((DataRowView)e.Item.DataItem).Row;
LinkButton lnkcoursename = (LinkButton)e.Item.FindControl("lnkCategory");
Label lblcount = (Label)e.Item.FindControl("lblCount");
string k = lnkcoursename.CommandArgument.ToString();
if (k != "0")
{
TrainingCourse traningCourse = new TrainingCourse();
int count = traningCourse.CourseCount(Convert.ToInt32(k), "", "");
if (count == 0)
{
//This code is not working
dr.Delete();
dr.AcceptChanges();
}
else
{
lblcount.Text = "(" + count + ")";
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,如果我发现count = 0,那么我想从转发器中删除该行.我不想从数据库中删除它然后重新绑定它......
我试图将Linq var转换为List.my c#代码是
private List<HyperlinkInfo> GetHyperlinkByCode()
{
TourInfoBusiness obj = new TourInfoBusiness();
List<HyperlinkInfo> lst = new List<HyperlinkInfo>();
lst = obj.GetAllHyperlink();
//lst = lst.Select(x => x.Attraction).ToList();
var k = lst.Select(x => x.Attraction).Distinct();
}
Run Code Online (Sandbox Code Playgroud)
如果你查看上面的代码,直到Line var k = lst.Select(x => x.Attraction).Distinct();
为OK现在可以将var k转换为List.
我有一个数据集 Dataset1 并且我正在显示基于分组的数据。数据是这样的
CityColumn CountColumn
City1 5
City2 3
Run Code Online (Sandbox Code Playgroud)
上述数据的查询是这样的:
select count(*) as "CountColumn" from City group by CityColumn
Run Code Online (Sandbox Code Playgroud)
在上面的数据集中,我在CityColumn
.
现在我创建了另一个数据集 Dataset2 并且数据是这样的
CityColumn
City1
City2
City3
Run Code Online (Sandbox Code Playgroud)
现在在 dataset2 中,我添加了一个名为 TotalCount 的计算字段并使用了查找函数,该函数是这样的
=Lookup(CityColumn, CityColumn, CountColumn, "Dataset1")
Run Code Online (Sandbox Code Playgroud)
但它给了我一个错误
查找包括聚合、行号、运行值、前一个或查找函数。Aggregate、rownumber、runningvalue、previous 或lookup 函数不能在计算字段中使用。
我已经搜索了但是我没有得到像sql中的21-Sep-12日期格式的格式.我得到所有其他格式但我没有得到这种类型的Format.so,我怎样才能在Date中获得这样的格式?