小编Raz*_*t4x的帖子

计算MS-Access中同一字段中的两种值

我有这个表customerDetail,其中有一个字段c_type,其中"a"代表"active"而"d"代表"not-active".现在我必须在同一查询中找到它们的计数.
我用过这些但没有结果.

SELECT Count(c_type) AS Active, Count(c_type) AS Not_Active  
FROM customerDetail  
WHERE c_type="a" OR c_type="d"
Run Code Online (Sandbox Code Playgroud)

当然我知道它看起来很脏,但我也尝试了这个,但这也没有用 -

SELECT
    Count(customerDetail.c_type) AS Active,
    Count(customerDetail_1.c_type) AS Not_Active  
FROM customerDetail INNER JOIN customerDetail AS customerDetail_1  
ON customerDetail.Id=customerDetail_1.Id  
WHERE (customerDetail.c_type="a") AND (customerDetail_1.c_type="d")
Run Code Online (Sandbox Code Playgroud)

但是它也没有用,所以有人可以告诉我,我应该如何知道同一查询中活动和非活动的计数?

sql t-sql ms-access ms-access-2007

3
推荐指数
1
解决办法
3483
查看次数

用jquery将&符号传递给ajax?

我有这个ajax电话

 function addNewRemarksToDataBase(argRemark) {
            if (argRemark != '') {
                // if not blank
                $.ajax({
                    url: '../AutoComplete.asmx/AddNewRemarks',
                    type: 'POST',
                    timeout: 2000,
                    datatype: 'xml',
                    cache: false,
                    data: 'argRemarks=' + argRemark,
                    success: function (response) {
                        // update the field that is source of remarks
                        updateRemarksSource();
                    },
                    error: function (response) {
                    }
                });
            }
        };
Run Code Online (Sandbox Code Playgroud)

该方法定义为

[WebMethod]
public void AddNewRemarks(string argRemarks)
{
    BAL.BalFactory.Instance.BAL_Comments.SaveRemarks(argRemarks, Globals.BranchID);
}
Run Code Online (Sandbox Code Playgroud)

问题是如果用户输入long & elegant类似的内容smart & beautiful,包含的东西&,我只得到之前的第一部分&,long(在第一种情况下),smart(在第二部分中)(也注意到空白!)

我在jquery …

ajax jquery

3
推荐指数
1
解决办法
2751
查看次数

根据两个输入找到一个独特的输出?

我需要找到一种方法,这样用户必须输入2个数字(int),并且对于每个不同的值,返回单个输出(最好是int).假设用户输入6, 8它返回k当用户输入任何其他类似6,79,8其他任何输入时(m, n除非6, 8(即使只更改了一个输入))产生完全不同的输出.但问题是,它应该是唯一的,m, n所以我不能使用像是m*n因为6 X 4 = 24但也是,12 X 2 = 24所以输出不是唯一的,所以我需要找到一种方法,对于每个不同的输入,有一个完全不同的输出,是没有重复任何其他价值.

编辑:回应尼古拉斯:输入范围可以是任何但不到1000(但当然超过1)!

编辑2:响应Rawling,我可以使用long(Int64)但不优选使用float或doulbe,因为这个输出将用于for循环,而float和double对于for循环来说很糟糕,你可以在这里查看

c# algorithm math unique

2
推荐指数
2
解决办法
1640
查看次数

如何阻止方法递归调用自己?

我有两个表,employeesprojectlistbox2中,我告诉所有的employees,并在listbox1所有的projects,现在显然一个员工都可以参与许多项目和一个项目可以有很多的员工.所以我有这个EmployeeProject映射存在的多对多关系.我想要的是,如果用户在第一个列表框中单击项目名称,则应该在listbox2中选择该项目中的所有员工.此外,当用户单击listbox2中的项目时,(员工)应该在listbox1中选择该员工所属的所有项目

但是,如果我为此进程使用ListBox.SelectedIndexChanged事件,并在listbox2中选择甚至单个值,那么它将触发listbox2的SelectedIndexChagned,并且将通过选择当前员工所属的listbox1中的所有项目开始工作,但是一旦选择了listbox1中的一个项目,它就会激活其SelectedIndexChanged事件,并且它将永远像这样继续.那么这个解决方案是什么?到目前为止,我已经做到了这一点..

 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Load the list of employees
            cmd.CommandText =
                "SELECT EmpName FROM Employee WHERE EmpID IN(SELECT EmpID FROM EmployeeProject WHERE ProjectID =(SELECT ProjectID FROM Project WHERE ProjectName = '" +
                listBox1.SelectedItem.ToString() + "')) ORDER BY EmpId";
            var rdr = cmd.ExecuteReader();
            listBox2.Items.Clear();
            // right now, I am doing this to escape this recursive loop, but thats not what …
Run Code Online (Sandbox Code Playgroud)

c# recursion listbox visual-studio

1
推荐指数
1
解决办法
485
查看次数

为什么这个方法在另一个方法中不起作用?

我有这个HTML表格:

<table id="languages" border="0" cellspacing="1">
  <thead>
    <tr>
      <th>Language</th>
      <th>Type</th>
      <th>Invented</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Java</td>
      <td>Static</td>
      <td>1995</td>
    </tr>
    <tr>
      <td>Ruby</td>
      <td>Dynamic</td>
      <td>1993</td>
    </tr>
    <tr>
      <td>Smalltalk</td>
      <td>Dynamic</td>
      <td>1972</td>
    </tr>
    <tr>
      <td>C++</td>
      <td>Static</td>
      <td>1983</td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

当我运行这个JavaScript时:

alert($('td').index($('td:contains(C++)')))
Run Code Online (Sandbox Code Playgroud)

我得到一个弹出窗口9,这是我所期待的.

当我运行时:alert($('td:eq(9)').text())弹出窗口说C++,再次与人们期望的一样.但是如果我尝试9在第二个选择器中放置第一个函数/选择而不是硬编码,就像这样......

alert($('td:eq($('td').index($('td:contains(C++)')))').text())
// just replacing the hard coded 9 with the first selector, as it gives a value of 9
Run Code Online (Sandbox Code Playgroud)

...什么都没发生.我没有得到任何弹出说法C++,这是人们所期望的,我没有得到任何弹出的问题.谁能告诉我我做错了什么?

javascript jquery selector

1
推荐指数
1
解决办法
69
查看次数

如何将自定义值传递给AutocompleteExtender?

我有这个文本框和AutocompleteExtender

<asp:TextBox ID="txtItemName" runat="server" ClientIDMode="Static"
MaxLength="300" onfocus="javascript:select();"
></asp:TextBox>
<cc1:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="txtItemName" EnableCaching="true"
ServicePath="~/AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="1" 
CompletionInterval="10" CompletionSetCount="15" FirstRowSelected="True" CompletionListCssClass="AutoExtender"
CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
>
</cc1:AutoCompleteExtender>
Run Code Online (Sandbox Code Playgroud)

并且该方法被定义为

[WebMethod]
public string[] GetCompletionList(string prefixText, int count, string contextKey)
{
List<string> items = new List<string>(count);
SqlCommand con = new SqlCommand();
SqlDataReader sdr = null;
DataSet ds = new DataSet();
try
{
    SqlCommand cmd = new SqlCommand();

    cmd.CommandText = "proc_NewBooking";
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@BranchId", Globals.BranchID);
    cmd.Parameters.AddWithValue("@ItemName", prefixText.ToString());
    cmd.Parameters.AddWithValue("@Flag", 11);
    sdr = AppClass.ExecuteReader(cmd);
    ds = AppClass.GetData(cmd);
    while …
Run Code Online (Sandbox Code Playgroud)

ajax autocomplete ajaxcontroltoolkit

1
推荐指数
1
解决办法
5690
查看次数

如何在ASP.NET/WCF中定期执行某些操作?

首先抱歉提出这样一个愚蠢的问题,我是asp.net中的新手.

所以,我应该定期做一些事情,说我是网站heartpatients.com的所有者(假设),我希望我的每个网站用户访问该网站,2小时后显示一条消息"拿你的药".所以,基本上这都是我的问题,我应该在每2小时(或4,6之后的任何时间)之后显示此消息,我也可以如何自定义时间.
还有一件事,比如我在WCF服务中有这个方法,它显示了这条消息,如何在特定时间调用该服务,甚至用户配置(比如有人在10小时后吃药?)那么如何在用户指定的时间后定期传递该服务(服务中的特定方法)?

我希望我的问题很清楚.
任何帮助表示赞赏.

c# asp.net wcf multithreading web-services

0
推荐指数
1
解决办法
1346
查看次数

不能在Dictionary <int,List <Int32 >>的List <Int32>中存储超过11个项目

好的,所以你从标题中得到了想法,让我发布代码并在评论中我会解释发生了什么(以及应该做什么!)

// select distinct subject from database
cmd.CommandText = "SELECT DISTINCT SubjectId  FROM ClassSubject";
// a new command
OleDbCommand cmdTemp = new OleDbCommand();
// con id defined earlier
cmdTemp.Connection = con;
// Reader for outer loop
OleDbDataReader rdr;
// reader for inner loop
OleDbDataReader rdrTemp;
// reader for main command, that is for each subject
rdr = cmd.ExecuteReader();
// this will store subject id
int nTempID;
// this is the list that is supposed to contain all the classes (many …
Run Code Online (Sandbox Code Playgroud)

c# sql generics .net-3.5 visual-studio-2008

0
推荐指数
1
解决办法
126
查看次数

这个条件运算符有什么问题?

protected void MakeAutoComplete(ref Control control, IListSource dListSource)
    {
        MakeAutoComplete(ref control, dListSource, false);
    }

protected void MakeAutoComplete(ref Control control, IListSource dListSource, bool isComboBox)
    {
        var curControl = (isComboBox) ? (control as ComboBox) : (control as TextBox);
        // other
    }
Run Code Online (Sandbox Code Playgroud)

上线var curControlVS给我的错误 Type of conditional expression cannot be determined because there is no implicit conversion between 'System.Windows.Forms.ComboBox' and 'System.Windows.Forms.TextBox',我可以理解的错误,我知道有没有投BTW TextBoxComboBox,但是这就是为什么我使用var摆在首位.所以有什么问题?为什么抱怨?

c# visual-studio-2010 c#-4.0

0
推荐指数
1
解决办法
117
查看次数

DataTable是通过引用传递的吗?

这听起来像是一个愚蠢的问题,但我偶然发现了这一点.我知道您可以使用ref通过引用传递参数.但我有这种方法

    public void SaveRecordsIntoTemporaryTable(DataTable objDataTable, string userSessionID)
   {

       // The objDataTable has 5 columns "Id", "Name", "Tag_1", "Tag_2", "Tag_3"
       // Now in here I remove "Tag_1", "Tag_2", and "Tag_3"
       objDataTable.Columns.Remove("Tag_1");
       objDataTable.Columns.Remove("Tag_2");
       objDataTable.Columns.Remove("Tag_3");

       ...

   }
Run Code Online (Sandbox Code Playgroud)

现在我在第三行设置了一个调试点,但在删除此列后,我将"Tag_3"光标悬停objDataTable在参数中,DataTable它显示还删除了列?那么,它是通过引用传递的吗?

UPDATE

好吧,如果它过去了reference,如果我使用它会有什么不同ref

.net c#

0
推荐指数
1
解决办法
8038
查看次数

数字的正则表达式?

我需要一些帮助来找到适合我需要的正则表达式,我想要的是输入可以是任何字符串,正则表达式找到任何和所有整数值并返回它们,比如说

string s1 = "This is some string"
string s2 = " this is 2 string"
string s3 = " this is 03 string"
string s4 = "4 this is the 4th string"
string s5 = "some random string: sakdflajdf;la  989230"
string s6 = "3494309 !@# 234234"
Run Code Online (Sandbox Code Playgroud)

现在我想要的是正则表达式返回,

for s1 = return null (// nothing)
s2 = return 2
s3 = return 0 and 3 (// may separately as 0 and 3 or together as 03 doesn't matter)
s4 = …
Run Code Online (Sandbox Code Playgroud)

c# regex

-6
推荐指数
1
解决办法
235
查看次数