gpt4 book ai didi

c# - SQL Azure 连接因大型 json 字符串而关闭

转载 作者:行者123 更新时间:2023-12-03 05:57:23 30 4
gpt4 key购买 nike

我尝试将较大的 json 字符串 (c.2Mb) 保存到 SQL Azure 数据库中的 NVARCHAR(MAX) 列,但出现以下异常:

[SqlException (0x80131904): A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)]

如果我将 json 字符串设置为“”,则 INSERT 语句可以正常工作。我已经用相同的方法成功保存了其他较小的 json 字符串。异常会立即抛出,因此不会感觉超时。尽管如此,我尝试更改连接和命令超时,但无济于事。

我正在使用 Dapper 与 SQL 对话:

 public async Task<PublisherDto> SaveNewAsync(PublisherDto publisher, int userID)
{
using (var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
{
var b = await cnn.QueryAsync<PublisherDto>("s_PublisherInsert", new
{
publisher.cv_id,
publisher.Name,
publisher.ThumbImageUrl,
publisher.FullImageUrl,
userID,
publisher.cv_Url,
publisher.JsonData,
publisher.cv_version_hash
}, commandType: CommandType.StoredProcedure, commandTimeout: 60);
return b.FirstOrDefault();
}
}

有人遇到过同样的问题并且有解决办法吗?

最佳答案

尝试将超时设置为更高的值。根据文档,错误与超时有关。

https://support.microsoft.com/en-us/kb/555938

希望有帮助。

-RN

关于c# - SQL Azure 连接因大型 json 字符串而关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39056732/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com