我有一个在 Visual Studio 2015 和 TFS 源代码管理中使用 SSDT(SQL Server Data Tools)的数据库项目。
今天早上,当我尝试比较两个数据库(DB -> TFS)时,它不起作用,并且出现错误:
比较完成。检测到差异。有限的比较。详细信息请参见错误列表
错误列表窗口中的警告是:
严重性代码 描述 项目文件行抑制状态 警告 目标的登录名没有 VIEW ANY DEFINITION 权限。如果源是数据库,则比较将仅限于数据库范围的元素。
SSDT 的 SQL Server 用户是sa。
提前致谢
更新: 我通过以下查询修复了比较警告,但主要问题仍然存在:
USE [master]
GO
Grant VIEW ANY DEFINITION to [USERNAME];
GO
USE [DBNAME]
GO
GRANT CONNECT to [USERNAME]
GRANT VIEW DEFINITION TO [USERNAME]
Run Code Online (Sandbox Code Playgroud) 我有UIViewController与UINavigationBarDelegate代表和我一组的一切程序和我的应用程序是多语言,所以我喜欢在导航栏每个部分需要RTL(从右到左)的支持。我使用了这种方法:
if MSGlobal.setting.language.direction == .L2R
{
navigationItem.setRightBarButtonItems(rightItems, animated: true)
}
else
{
navigationItem.setLeftBarButtonItems(rightItems, animated: true)
}
let stackCount = navigationController!.viewControllers.count
if stackCount == 1
{
let leftBtnItem:UIBarButtonItem = UIBarButtonItem(image: UIImage(named:"drawer"), landscapeImagePhone: UIImage(named:"drawer"), style: UIBarButtonItemStyle.Plain, target: self, action: "cb_drawerTapped:")
if MSGlobal.setting.language.direction == .L2R
{
navigationItem.setLeftBarButtonItem(leftBtnItem, animated: true)
}
else
{
navigationItem.setRightBarButtonItem(leftBtnItem, animated: true)
}
}
else
{
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: self, action: "cb_back:")
}
Run Code Online (Sandbox Code Playgroud)
在 LTR 语言(如英语)中一切正常,但在 RTL 语言中未显示后退按钮。我的结果一定是这样的:
LTR: [ < Title …Run Code Online (Sandbox Code Playgroud) 我需要ModelState在Asp.net Core 2.1中间件中进行访问,但这仅可从访问Controller。
例如,我有ResponseFormatterMiddleware一个中间件,在这个中间件中,我需要忽略ModelState错误,并在“响应消息”中显示错误:
public class ResponseFormatterMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger<ResponseFormatterMiddleware> _logger;
public ResponseFormatterMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
{
_next = next ?? throw new ArgumentNullException(nameof(next));
_logger = loggerFactory?.CreateLogger<ResponseFormatterMiddleware>() ?? throw new ArgumentNullException(nameof(loggerFactory));
}
public async Task Invoke(HttpContext context)
{
var originBody = context.Response.Body;
using (var responseBody = new MemoryStream())
{
context.Response.Body = responseBody;
// Process inner middlewares and return result.
await _next(context);
responseBody.Seek(0, SeekOrigin.Begin);
using (var streamReader = …Run Code Online (Sandbox Code Playgroud) 我是C#编码的新手,并且环顾四周,但很难推断出我的问题的答案.
我目前只是试图将组合框中的文本和选定文本添加到简单的数据库表中.但是,当我尝试添加信息时,我得到一个SqlException错误未处理.我已经查看了其他答案,看到它可能与添加连接有关,我尝试过但它仍然无法正常工作......
我的代码和错误消息,如下面的图像链接,但以防万一这里也是我的代码,
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace SavetoDbTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (SqlConnection test = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\User\\Documents\\Visual Studio 2015\\Projects\\SavetoDbTest\\SavetoDbTest\\Hobbie.mdf;Integrated Security=True"))
{
using (SqlCommand again = new SqlCommand())
{
again.CommandText = "INSERT INTO Table Values('" + textBox1.Text + "', '" + comboBox1.Text + "')";
again.Parameters.AddWithValue("@Name", textBox1.Text);
again.Parameters.AddWithValue("@Hobby", comboBox1.Text); …Run Code Online (Sandbox Code Playgroud) 这部分代码应该不言而喻,我的问题是我可以在 res 变量中得到 1242.08 结果,而不是 1242.07,因为在数学中
b = 1/(1/b)
Run Code Online (Sandbox Code Playgroud)
在精度较低的 double 中,我似乎得到了不错的结果
我可以修复计算的小数部分以给出数学上正确的结果吗:
decimal rate = 124.2075M;
decimal amount = 10M;
decimal control = decimal.Round(rate * amount, 2); //it is 1242.08
//but
decimal res = decimal.Round(amount * (1 / (1 / rate)), 2);//1242.07 - should be 1242.08
decimal res1 = decimal.Round(amount * 124.2075M, 2);//1242.08 OK
/////////////////////////////////////////////////////////////
//while with double seems OK
double ratef = 124.2075;
double amountf = 10;
double resf = Math.Round(amountf * (1 / (1 / ratef)), 2);//1242.08 …Run Code Online (Sandbox Code Playgroud) c# ×3
sql-server ×2
ado.net ×1
asp.net-core ×1
decimal ×1
double ×1
ios ×1
localization ×1
robots.txt ×1
seo ×1
sql ×1
swift ×1