我尝试将较大的 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();
}
}
有人遇到过同样的问题并且有解决办法吗?
最佳答案
关于c# - SQL Azure 连接因大型 json 字符串而关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39056732/