小编use*_*440的帖子

选择查询以从SQL Server获取数据

我试图在我的C#代码中运行SQL Select查询.但我总是得到-1输出

int result = command.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用delete或insert工作相同的表...

ConnectString 也没关系.

请检查以下代码

SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=");
conn.Open();

SqlCommand command = new SqlCommand("Select id from [table1] where name=@zip", conn);

//command.Parameters.AddWithValue("@zip","india");
int result = command.ExecuteNonQuery();

// result gives the -1 output.. but on insert its 1
using (SqlDataReader reader = command.ExecuteReader())
{
    // iterate your results here
    Console.WriteLine(String.Format("{0}",reader["id"]));
}

conn.Close();
Run Code Online (Sandbox Code Playgroud)

查询在SQL Server上运行正常,但我不知道为什么只有select查询不起作用.

所有其他查询都有效.

c# sql sql-server asp.net

14
推荐指数
3
解决办法
20万
查看次数

iOS获取国家/地区代码无效

我正在使用iphone5s,我从美国购买并在印度使用相同的iphone5s进行开发也使用印度航空公司.我试图获得国家代码,NSLocale但这给了我US,而不是IN.

我该怎么做才能做到 IN

NSLocale *currentLocale = [NSLocale currentLocale];  // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
NSLog(@"country code %@",countryCode);  //US 
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios nslocale

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

Java转到下一个5000

我正在寻找一些java math.round公式,它可以转换为最近的5000值.假设值为15555,则应转换为20000.如果值为18555,则还应转换为20000(因为这应该给出下一个5000范围).到目前为止,我正在尝试这个:

Math.round(value/ 5000.0) * 5000.0)
Run Code Online (Sandbox Code Playgroud)

但如果值是15555,这给了我15000.我希望这是20000

java math calculus

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

标签 统计

asp.net ×1

c# ×1

calculus ×1

ios ×1

iphone ×1

java ×1

math ×1

nslocale ×1

sql ×1

sql-server ×1

xcode ×1