【发布时间】:2016-11-16 19:53:24
【问题描述】:
我有一个只有一张表的新 SAP ASE 数据库,而这张表只有三列 - 两列 varchar 列和一列图像。
使用从 SAP ASE 数据库的开发人员版中获取的纯 ADO.NET 提供程序,我只是想在此表中插入一条包含文件内容的记录 - 我的第一次试验是使用 3kb 文件,它的工作方式类似于一种魅力。然后,我拿了一个大约 900kb(肯定小于 1MB)的 PDF,应用程序给了我一个超时;更丑的是,不知何故,整个数据库都被阻塞了——我不得不重新启动服务以使其再次工作。
所以,现在让我们来看看代码 - 如果有人可以引导我走向正确的方向,我将不胜感激。
static void Main(string[] args)
{
using (AseConnection aseConnection =
new AseConnection(
"data source=...;initial catalog=...;User ID=...;Password=...;Port=...;ConnectionIdleTimeout=600;CommandTimeOut=0;ConnectionTimeOut=0;Pooling=False;TextSize=10000000")
)
{
aseConnection.Open();
Console.WriteLine(aseConnection.State.ToString());
AseCommand setTextSizeCommand = new AseCommand("SET TEXTSIZE 10000000", aseConnection);
setTextSizeCommand.ExecuteNonQuery();
byte[] fileContent = File.ReadAllBytes(@"d:\adonet.pdf");
//byte[] fileContent = File.ReadAllBytes(@"d:\rack.txt");
AseCommand aseCommand = new AseCommand("insert into xxx(web_id, doc_name, doc_file) values(?, ?, ?)", aseConnection);
aseCommand.Parameters.Add(0, AseDbType.VarChar, 20).Value = "100";
aseCommand.Parameters.Add(1, AseDbType.VarChar, 100).Value = "fisier";
aseCommand.Parameters.Add(2, AseDbType.Image, fileContent.Length).Value = fileContent;
aseCommand.NamedParameters = false;
aseCommand.CommandTimeout = 65000;
aseCommand.ExecuteNonQuery();
}
}
ASE Client dll 的版本是 16.0.2.2。
非常感谢!
【问题讨论】:
-
如果增加
TimeOut值会怎样? -
nothing :( 如您所见 - 它设置为 65000 秒......它等待,它等待......
-
也许这会有所帮助:infocenter.sybase.com/help/topic/…,顺便问一下,您为什么使用 AseDbType.Image 而不是二进制文件?
-
我无法控制结构 :( 我只有一个必须使用的架构 :( - 无论如何我已修复它 - 我将在一秒钟内发布修复程序。