小编Tim*_*per的帖子

只更新了1条记录时,ExecuteNonQuery返回值2

运行Enterprise Library 5.0的示例,当我使用ExecuteNonQuery运行更新sproc时,它返回2.更新基于ProductID,表的主键(是的,我检查过,它是唯一的).

这是简单的sproc:

ALTER PROCEDURE [dbo].[UpdateProductsTable]
     @ProductID int, 
     @ProductName varchar(50) = NULL, 
     @CategoryID int = NULL, 
     @UnitPrice money = NULL
AS
BEGIN
    UPDATE Products
    SET 
        ProductName = @ProductName, 
        CategoryID = @CategoryID, 
        UnitPrice = @UnitPrice
    WHERE ProductID = @ProductID
END
Run Code Online (Sandbox Code Playgroud)

在SSMS中执行此sp在查询结果窗口的右下角显示"1行",并在网格中返回0.单击消息选项卡显示

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)
Run Code Online (Sandbox Code Playgroud)

不知道为什么我在这里看到这3次,但我不相信这是问题所在.

这是调用sp的代码:

public static void Exec_Update_Query()
        //updates a column of a single row, checks that the update succeeded, and then update it again to return it to the original value …
Run Code Online (Sandbox Code Playgroud)

enterprise-library executenonquery c#-4.0

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

reloadData - UITableView

我在表格中显示数据时遇到问题,在Tebel更新时调用方法[tv reloadData]但是当我选择一行时它会显得模糊,好像之前的数据没有被删除一样.我认为问题存在于存储我的SQL查询带来的数据的类中,但是我在所有字段中都有一个[release]并且不起作用.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  {

    iMAPArrayProdutos *ArrayProdutos = (iMAPArrayProdutos *)[iMAP objectAtIndex:indexPath.row];

    NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row];

    iMAPTabela *cell = (iMAPTabela *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    tv.autoresizesSubviews = YES;

    if (cell == nil) {

        cell = [[[iMAPTabela alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }

    UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0, 50.0, tableView.rowHeight)] autorelease];

    [cell addColumn:70];

    label.tag = TAG_1; 
    label.font = [UIFont systemFontOfSize:12.0]; 
    label.text = ArrayProdutos.Cod;
    label.textAlignment = UITextAlignmentRight; 
    label.textColor = [UIColor blueColor]; 
    label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; 

    [cell.contentView addSubview:label]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

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

c字符串拷贝与strncpy

我对strncpy功能感到非常沮丧.我做了这样的事情:

char *md5S; //which has been assign with values, its length is 44
char final[32];
strncpy(final,md5S,32);
Run Code Online (Sandbox Code Playgroud)

但不知何故,长度char final[]超过32后.
我该怎么办?

c string

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

用另一个替换字符串的一部分

我正在制作一个解决方程的程序.

我有一个更改的变量:i和输入的字符串:parseLine

什么是最简单的方法:

parseLine = "100 + x"
when i = 1;
Run Code Online (Sandbox Code Playgroud)

成:

"100 + 1"
Run Code Online (Sandbox Code Playgroud)

我试过了

String ir = Double.toString(i);
parseLine.replace("x", ir);
Run Code Online (Sandbox Code Playgroud)

但输出仍然是 100 + x

java string

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

clock()在调试版上运行良好但在发布时不起作用(C++ VS2010)

这是我的代码:

// Start performance test clock
assert((start=clock())!=-1);

// Some reading and writing methods

// Get stop time
stop = clock();

cout << stop << endl;

// Calculate operation time
double result = (double)(stop-start)/CLOCKS_PER_SEC;

// Print result
cout << "--> Finished analysing in " << result << "s" << endl;
Run Code Online (Sandbox Code Playgroud)

我调试程序时效果很好,但是当我运行发布版本时,stop会收到比start更小的值,结果是负数.

有任何想法吗?

c++ release timer clock

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

使用toast从catch语句显示错误消息

我的Android应用程序中有以下catch语句,我想通过toast显示任何错误消息,我可以这样做吗?

catch (Exception e) 
{
    //Helper.displayExceptionMessage(this, e.getMessage());
    Toast.makeText(this, error, Toast.LENGTH_SHORT).show();
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
public static void displayExceptionMessage(Context context, String msg)
{
    Toast.makeText(context, msg , Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)

我还尝试创建一个帮助类来显示消息,但我不知道如何解决"帮助器".

java android

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

安装Google API时拒绝访问

使用SDK Manager在Eclipse中安装7​​级Google API时出现错误:

找不到文件:C:\ Program Files(x86)\ Android\android-sdk\temp\google_apis-7_r01.zip(访问被拒绝)完成.什么都没安装

这是预期的吗?

android eclipse-plugin android-sdk-2.1

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

memcpy一个子串

我想试试C memcpy函数.我有这个代码:

char destination[40];
memcpy(destination, "My favorite destination is...", 11);
printf(destination);
Run Code Online (Sandbox Code Playgroud)

我想将前11个字母复制到目标数组.当我使用printf时,结果是"我最喜欢的2".为什么?

c substring memcpy

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

go中的非阻塞通道操作.发送?

我正在通过示例:非阻塞频道操作

据我了解,第一个select是触发default案例,因为messages渠道中没有任何内容,如果default案件不存在,我们会收到fatal error: all goroutines are asleep - deadlock!错误,对吧?

好吧,我无法弄清楚如何触发第二个select,特别是触发 case messages <- msg:

正如我所想,它应该与接收相反.因此,如果有2个消息的缓冲区并且我们将第3个消息发送到通道,它将触发该default子句,但是messages通道是空的,那么为什么在第二个选择中它会触发该default子句?我该如何触发该case messages <- msg:条款?

channel go

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

子匹配中的正则表达式替换

给定一个字符串(日志文件中的一行):

Date=2017-06-29 03:10:01.140 -700 PDT,clientDataRate="12.0,18.0,24.0,36.0,48.0,54.0",host=superawesomehost.foo,foo=bar
Run Code Online (Sandbox Code Playgroud)

我想用一个空格替换逗号,但只能在双引号内。

想要的结果:

Date=2017-06-29 03:10:01.140 -700 PDT,clientDataRate="12.0 18.0 24.0 36.0 48.0 54.0",host=superawesomehost.foo,foo=bar
Run Code Online (Sandbox Code Playgroud)

我已经开始使用正则表达式和 ReplaceAllString 的基本组合,但我很快意识到我不明白如何实现实现这一点所需的匹配组 (?)。

package main

import (
    "fmt"
    "log"
    "regexp"
)

func main() {
    logLine := "Date=2017-06-29 03:10:01.140 -700 PDT,clientDataRate=\"12.0,18.0,24.0,36.0,48.0,54.0\",host=superawesomehost.foo,foo=bar"
    fmt.Println("logLine:        ", logLine)

    reg, err := regexp.Compile("[^A-Za-z0-9=\"-:]+")
        if err != nil {
                log.Fatal(err)
        }

    repairedLogLine := reg.ReplaceAllString(logLine, ",")
    fmt.Println("repairedLogLine:", repairedLogLine )   
}
Run Code Online (Sandbox Code Playgroud)

非常感谢所有帮助。

regex go

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