小编Gre*_*reg的帖子

存储过程中表变量的复合主键

我是存储过程的新手,并尝试将复合主键添加到表变量中.

DECLARE @statistictemp TABLE (
    MajorName      VARCHAR(50) NOT NULL, 
    SubName       VARCHAR(50) NOT NULL, 
    DetailedName   VARCHAR(50) NOT NULL, 
    UniversityID   SMALLINT    NOT NULL, 
    StatisticValue DECIMAL(9,3)
);

ALTER TABLE @statistictemp 
ADD CONSTRAINT pk_statistictemp 
PRIMARY KEY (MajorName, SubName, DetailedName, UniversityID);
Run Code Online (Sandbox Code Playgroud)

我对得到一个错误ALTER TABLE @statistictemp说法

Incorrect syntax near '@statistictemp'. Expecting ID, QUOTED_ID, or '.'.

我在这做错了什么?如何将复合主键添加到表变量?

sql sql-server stored-procedures primary-key sql-server-2008

45
推荐指数
1
解决办法
5万
查看次数

在RAISERROR中连接消息

这里的语法是什么?

If (@timestamp < (Select PromoStartTimestamp From @promo))
    RAISERROR('Code not valid until ' + (Select PromoStartTimestamp From @promo)
              ,16
              ,1);
Run Code Online (Sandbox Code Playgroud)

我试过了:

If (@timestamp < (Select PromoStartTimestamp From @promo))
    RAISERROR(N'Code not valid until @starttimestamp'
              ,16
              ,1
              ,(Select PromoStartTimestamp From @promo));
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2008

30
推荐指数
1
解决办法
2万
查看次数

使用Authorize.Net C#SDK使用银行帐户

在使用Authorize.Net CIM XML API C#示例代码之后,我开始使用Authorize.Net C#SDK.我可以使用CIM XML API示例代码将信用卡和银行帐户添加到客户配置文件中.我不知道如何使用SDK添加银行账户.

使用CIM XML API添加银行帐户:

...
customerPaymentProfileType new_payment_profile = new customerPaymentProfileType();
paymentType new_payment = new paymentType();

bankAccountType new_bank = new bankAccountType();
new_bank.nameOnAccount = "xyz";
new_bank.accountNumber = "4111111";
new_bank.routingNumber = "325070760";
new_payment.Item = new_bank;

new_payment_profile.payment = new_payment;

createCustomerPaymentProfileRequest request = new createCustomerPaymentProfileRequest();
XmlAPIUtilities.PopulateMerchantAuthentication((ANetApiRequest)request);

request.customerProfileId = profile_id.ToString();
request.paymentProfile = new_payment_profile;
request.validationMode = validationModeEnum.testMode;
...
Run Code Online (Sandbox Code Playgroud)

使用SDK我只看到一种.AddCreditCard()方法,但无法添加银行帐户.当我遍历所有我的PaymentProfilesIt时,当它遇到一个银行帐户时会引发异常:

CustomerGateway cg = new CustomerGateway("xxx", "yyy");

foreach (string cid in cg.GetCustomerIDs())
{
    Customer …
Run Code Online (Sandbox Code Playgroud)

c# authorize.net payment-gateway

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

在appSettings中存储字符串数组?

我想将一维字符串数组存储为我的条目appSettings.我不能简单地用元素分隔元素,,或者|因为元素本身可以包含那些字符.

我正在考虑存储数组,JSON然后使用它反序列化它JavaScriptSerializer.

有没有"正确"/更好的方法来做到这一点?

(我的JSON想法有点像hacky)

.net asp.net app-config web-config asp.net-4.0

26
推荐指数
6
解决办法
3万
查看次数

PHP致命错误:调用未定义的函数mssql_connect()

我之前从未使用过php,并且正在尝试连接到运行IIS7和PHP5.3的Windows机器上的SQL Server 2008实例.

SQLSRV30.EXE这里下载并安装了C:\Program Files (x86)\PHP\ext添加到C:\Program Files (x86)\PHP\php.ini:

extension=php_sqlsrv_53_nts.dll
Run Code Online (Sandbox Code Playgroud)

然后重新启动整个服务器.我的日志文件中仍然会出现致命错误:

PHP Fatal error:  Call to undefined function mssql_connect()
Run Code Online (Sandbox Code Playgroud)

从IIS7/Windows Server 2008上运行的PHP 5.3连接到Microsoft SQL Server 2008需要做什么?我敢肯定,我很遗憾......

完整的PHPINFO - > http://demo.mandibleweb.com/zapified/hello.php

phpinfo()函数:

PHP Version 5.3.10





System 

Windows NT MWD001 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 



Build Date 

Feb 2 2012 20:10:58 



Compiler 

MSVC9 (Visual C++ 2008) 



Architecture 

x86 



Configure Command 

cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" …
Run Code Online (Sandbox Code Playgroud)

php sql-server iis iis-7

19
推荐指数
1
解决办法
18万
查看次数

'event.layerX和event.layerY在WebKit中被破坏和弃用.错误

我刚刚将Chrome更新到版本16.0.912.63,现在我使用jQuery 1.7.1获得了数百个错误.鼠标移动时似乎会触发......

event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.
Run Code Online (Sandbox Code Playgroud)

我应该担心吗?是否有其他人收到这些错误?

我的用户:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Run Code Online (Sandbox Code Playgroud)

更新:在我的情况下,它是Chrome扩展程序"按图搜索(由Google)1.1.0".我只是禁用它,它与我的应用程序无关.

jquery google-chrome

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

Mongo查询子文档的多个字段

假设我有一个这样的集合:

{ "arr" : [ { "name" : "a", "num" : 1 }, { "name" : "a", "num" : 2 } ] },
{ "arr" : [ { "name" : "b", "num" : 1 }, { "name" : "a", "num" : 2 } ] },
{ "arr" : [ { "name" : "b", "num" : 1 }, { "name" : "b", "num" : 2 } ] }
Run Code Online (Sandbox Code Playgroud)

我想找到所有arr包含a name="b"和num= 2 的子文档的文档.

如果我这样做一个查询:

db.collection.find({
    $and: [ …
Run Code Online (Sandbox Code Playgroud)

mongodb mongodb-query

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

高效的DataTable Group By

我想在DataTable上执行聚合查询以创建另一个DataTable.我无法改变用于创建初始DataTable的SQL.

原始DataTable :(一切都是int)

TeamID | MemberID
-------|-----------
1      | 1
1      | 2
1      | 3
2      | 4
2      | 5
Run Code Online (Sandbox Code Playgroud)

期望的结果:

TeamID | MemberIDCount
-------|--------------
1      | 3
2      | 2
Run Code Online (Sandbox Code Playgroud)

如果它是SQL我可以做

Select TeamID, Count(*) From Table Group By TeamID
Run Code Online (Sandbox Code Playgroud)

但在我的应用程序中,我知道如何处理这个的唯一方法是这样的:

Dictionary<int,int> d = new Dictionary<int,int>();
foreach (DataRow dr in dt.Rows)
{
    if (d.ContainsKey(dr.ID))
    {
        d[dr.ID] = d[dr.ID] + 1;
    }
    else
    {
        d.Add(dr.ID, 1);
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有更好的办法?

c# asp.net datatable

13
推荐指数
2
解决办法
8万
查看次数

检查当前登录的用户是否具有持久性authcookie

我需要在当前登录用户的FormsAuthentication AuthCookie中编辑userdata.我不知道如何找出当前用户是否选择了持久性cookie("记住我").

//user is already logged in...

HttpCookie authCookie = FormsAuthentication.GetAuthCookie(username, ispersistant); //how to I determine 'ispersistant'?

FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, NEWuserdata);

authCookie.Value = FormsAuthentication.Encrypt(newTicket);

HttpContext.Current.Response.SetCookie(authCookie);
Run Code Online (Sandbox Code Playgroud)

有人有任何想法吗?谢谢

c# asp.net cookies persistence forms-authentication

12
推荐指数
2
解决办法
1万
查看次数

使用jQuery动态创建垂直分组的单选按钮

我正在使用jQuery mobile 1.0动态创建几个垂直分组的单选按钮,用于多项选择测验.

当我从JQM单选按钮文档中粘贴此代码时,它会正确地调整控件组的样式.

<fieldset data-role="controlgroup">
    <input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked" />
    <label for="radio-choice-1">Cat</label>
    <input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2"  />
    <label for="radio-choice-2">Dog</label>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

当我动态注入我的标记时,pageshow()会注入适当的标记,但它根本不会设置控件组的样式.

$.getJSON("assets/json/aircraft.json", function (data) {
    var maxQuestions = 10;
    var maxChoices = 4;

    var randomsorted = data.aircraft.sort(function (a, b) {
        return 0.5 - Math.random();
    });

    var quiz = $.grep(randomsorted, function (item, i) {
        return i < (maxQuestions * maxChoices);
    });

    var arr_quiz_markup = [];
    $.each(quiz, function (i, item) {
        var …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery-mobile

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