我的问题是我在创建用户后无法登录SQL Server.用户创建成功,因为新用户列在安全/登录下.
如何解决这个问题???
用户'sims'登录失败.用户未与受信任的SQL Server连接关联.(Microsoft SQL Server,错误:18452)
我想生成一个唯一的4位数随机数.这是我尝试的下面的代码:
生成随机数的代码
//Generate RandomNo
public int GenerateRandomNo()
{
int _min = 0000;
int _max = 9999;
Random _rdm = new Random();
return _rdm.Next(_min, _max);
}
Run Code Online (Sandbox Code Playgroud)
问题是我收到了一个随机的no值241,这个值不是4位数.代码有问题吗?
我有一个StudentReceipts存储表ReceiptNo作为string(001,002,003,..,099,..).
我想获取最后的receiptno详细信息,以便为下一个事务增加receiptno.
这就是我尝试过的
var _lastGeneratedRecDetails = _db.StudentReceipts
.AsEnumerable()
.Where(r => r.Status == true
&& EntityFunctions.TruncateTime(r.DueDate.Value) >= _startDate.Date
&& EntityFunctions.TruncateTime(r.DueDate.Value) <= _endDate.Date)
.OrderByDescending(x => Int32.Parse(x.ReceiptNo))
.FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
但是我得到以下例外
此函数只能从linq调用到实体
任何帮助将受到高度赞赏.
我有一个Employee页面,其中显示了具有编辑选项的员工列表.单击编辑按钮jquery-ajax用于从服务器获取数据.问题是,当我单击编辑按钮时,事件将触发两次.
我正在使用一个单独的js文件,并将该文件引用到主页面.脚本工作正常,直到我将其移动到单独的js文件.
Jquery脚本是
//ajaxGet on edit button click
$(document).on('click', '.editRole', ajaxGet);
var ajaxGet = function (e) {
var spinner = $(this).parent('div').find('.spinner');
var href = $("#editMenuSettings").data("url");
var menuRoleId = $(this).data('id');
spinner.toggle(true);
var options = {
type: "GET",
url: href,
data: { menuRoleId: menuRoleId }
};
$.ajax(options).success(function (data) {
spinner.toggle(false);
$(".modal-body").html(data);
$(".modal").modal({
backdrop: 'static'
});
});
$.ajax(options).error(function (data) {
spinner.toggle(false);
toastr.error("Oops..Some thing gone wrong");
});
return false;
};
Run Code Online (Sandbox Code Playgroud) 我使用ASP.Net中的Web服务使用jQuery自动完成.我使用自动完成来过滤员工代码.当页面加载自动完成工作正常,但是当我点击搜索按钮后自动完成功能无法正常工作.
我认为问题在于document.ready函数,所以当页面加载时工作正常,但我也要在buttonclick事件后使用自动完成功能.我怎样才能做到这一点 ???
继承我的jQuery自动完成功能
<link href="../AutoComplete/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="../AutoComplete/jquery.min.js" type="text/javascript"></script>
<script src="../AutoComplete/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=txtEmpcode.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/MyWebService.asmx/FetchEmpCode") %>',
data: "{ 'Empcode': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('-')[1],
//val: item
}
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
minLength: 1
}); …Run Code Online (Sandbox Code Playgroud) 我有一个筛选列表,它返回MenuTable中的所有distinctIds
var _parentList = _employee.Designation.Role.MenuRoles
.Select(x => new
{
MenuParentID = x.Menu.ParentID
})
.DistinctBy(x => x.MenuParentID)
.OrderBy(x => x.MenuParentID)
.ToList();
Run Code Online (Sandbox Code Playgroud)
我想选择所有项目,从menutable它是_parentList
这是我曾尝试和错误即将在_parentList.Contains(x.Id)这说Best overloaded match for System.Generic.contains has some invalid arguments.
MenuParentList = _db.Menus.Where(x => _parentList.Contains(x.Id))
.Select(x => new SMS.Models.ViewModel.DashboardVM.MenuParent
{
MenuParentID = x.Id,
MenuParentName = x.MenuName
})
.ToList()
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激
我有一个简单的场景.我想列出除登录用户以外的所有员工.
类似的SQL条件是
select * from employee where id not in(_loggedUserId)
Run Code Online (Sandbox Code Playgroud)
如何使用LINQ实现上述操作.我已尝试以下查询但未获得所需的列表
int _loggedUserId = Convert.ToInt32(Session["LoggedUserId"]);
List<int> _empIds = _cmn.GetEmployeeCenterWise(_loggedUserId)
.Select(e => e.Id)
.Except(_loggedUserId)
.ToList();
Run Code Online (Sandbox Code Playgroud) 我认为有一个简单的 LINQ 查询可以做到这一点,我只是不确定如何。请参阅下面的代码片段,评论解释了我想做的事情:
class Program
{
static void Main(string[] args)
{
List<Person> peopleList1 = new List<Person>();
peopleList1.Add(new Person() { ID = 1 });
peopleList1.Add(new Person() { ID = 2 });
peopleList1.Add(new Person() { ID = 3 });
peopleList1.Add(new Person() { ID = 4});
peopleList1.Add(new Person() { ID = 5});
List<Person> peopleList2 = new List<Person>();
peopleList2.Add(new Person() { ID = 1 });
peopleList2.Add(new Person() { ID = 4});
//I would like to perform a LINQ query to give me only
//those …Run Code Online (Sandbox Code Playgroud) 我有一个动态id元素"deleteSite"(在局部视图中)点击它将从表中删除该站点.当我点击它时,除第一个元素外,不会调用jquery函数(在父页面中).请帮我看看这里出了什么问题.
页面通常是正常加载的,但在分页期间通过ajax加载
这是我的部分观点
@model IPagedList<MvcSIMS.Models.Site>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th style="width: auto;">SlNo</th>
<th>SiteName</th>
<th>Remarks</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Select((x, i) => new { Data = x, Index = i }))
{
<tr>
<td>@(item.Index + ((Model.PageNumber - 1) * Model.PageSize) + 1)</td>
<td>@Html.DisplayFor(modelItem => item.Data.SITENAME)</td>
<td>@Html.DisplayFor(modelItem => item.Data.REMARKS)</td>
<td>
<a href="@Url.Action("Edit", new { id = item.Data.ID })" class="btn btn-sm btn-primary">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</a>
<a id="deleteSite" href="@Url.Action("Delete", new { id = item.Data.ID })" …Run Code Online (Sandbox Code Playgroud) 我的枚举列表中有以下项目
public enum Role
{
ED=1,
CPDHEAD=2,
CPD=3,
CENTERMANAGER=4,
ACCOUNTSHEAD=5,
MANAGER=6,
TECHNICALHEAD=7,
SALESINDIVIDUAL=8,
ACCOUNTS=9,
TECHNICALINDIVIDUAL=10
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得TechnicalHead和TechnicalIndividual重视List<int>
这是我尝试过但它返回枚举角色的所有值
List<int> _empRolelId = Enum.GetValues(typeof(EnumClass.Role))
.Cast<int>()
.Select(x => Convert.ToInt32(x))
.ToList();
Run Code Online (Sandbox Code Playgroud) 我正在尝试将数据插入到oracle数据库(版本11g xe).但是当我尝试使用toad执行该过程时,我得到的错误是'ORA-01403:没有找到数据'.这是我的代码
CREATE OR REPLACE PROCEDURE ACTSINFO.sp_Insert_WorkDetails
(p_workname IN varchar ,
p_workaddress IN varchar)
IS
BEGIN
insert into workdetails (workname,workaddress) values (p_workname,p_workaddress);
END sp_Insert_WorkDetails;
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下statememt执行该过程
EXEC sp_Insert_WorkDetails('test','test');
Run Code Online (Sandbox Code Playgroud)
此外,我已经为table workdetails中的workdetailsid自动增量定义了一个触发器和序列
顺序如下
ALTER SEQUENCE ACTSINFO.WORKDETAILS_WORKID_SEQ
INCREMENT BY 1
MINVALUE 0
MAXVALUE 9999999999999999999999999999
NOCACHE
NOCYCLE
NOORDER
Run Code Online (Sandbox Code Playgroud)
触发如下
DROP TRIGGER ACTSINFO.WORKDETAILS_INSERT;
CREATE OR REPLACE TRIGGER ACTSINFO.WORKDETAILS_INSERT
BEFORE INSERT
ON ACTSINFO.WORKDETAILS
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
BEGIN
SELECT WORKDETAILS_WORKID_SEQ.NEXTVAL INTO :NEW.WORKID FROM WORKDETAILS;
END;
Run Code Online (Sandbox Code Playgroud)
我是oracle的新手.请帮助我......
我在转发器中使用隐藏字段并尝试将其与menuid绑定,以便我可以从服务器端检索menuid.
但不知何故,我得到以下错误
Server Tag is not well formed
Run Code Online (Sandbox Code Playgroud)
我在转发器中使用的隐藏字段如下
<ul class="navBar" id="jsddm">
<asp:Repeater ID="rptHeaderMenu" runat="server">
<ItemTemplate>
<li>
<a href="<%#Eval("MENU_URL") %>"><%#Eval("MENU_NAME") %></a>
Hidden Filed => <asp:HiddenField ID="hFiledHdrMenuId" runat="server" Value="<%#Eval("MENU_ID") %>" />
<asp:Repeater ID="rptChildMenu" runat="server">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<a href="<%#Eval("MENU_URL") %>"><%#Eval("MENU_NAME") %></a>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
Run Code Online (Sandbox Code Playgroud) 我MVC Foolproof validation在我的申请中使用.方案是我有一个名为CustomerType的下拉列表,其中包含以下值
Id Name
1 Student
2 Non-Employed
3 Employed
4 SelfEmployed
Run Code Online (Sandbox Code Playgroud)
我的视图模型中还有一个属性.public string CompanyAddress{ get; set; }我的目标是使CompanyAddress required if下拉列表具有值3 or 4
我尝试了以下内容
[Required(ErrorMessage = "Please select status of the customer", AllowEmptyStrings = false)]
public int? customerTypeID { get; set; }
public SelectList customerTypeList { get; set; }
[RequiredIf("IsCompanyAddressRequired", true, ErrorMessage = "please enter company address")]
public string CompanyAddress { get; set; }
public bool IsCompanyAddressRequired
{
get
{
if (customerTypeID == 3 …Run Code Online (Sandbox Code Playgroud) c# ×7
linq ×4
jquery ×3
asp.net ×2
javascript ×2
.net ×1
ajax ×1
asp.net-mvc ×1
contains ×1
enums ×1
hidden-field ×1
oracle ×1
random ×1
razor ×1
repeater ×1
sql-server ×1
submit ×1