我返回從存儲過程(在SQL Server 2008)的靜態字符串如下:字符串的最大長度可以從存儲過程在SQL Server 2008中返回到.NET應用程序
select 'abcdefgh.........xyz'
如果靜態字符串長度超過某些限制(例如:8kb),則只有部分字符串(例如:7kb)返回到.net應用程序。
雖然我嘗試了不同的方式,如分配靜態字符串到varchar(max)
並選擇變量,仍然只返回部分字符串。
我應該返回完整的字符串,可能是最大5mb。因此,主要關注:
- 什麼是最大字符串長度,我可以從存儲過程
- 返回如何從存儲過程返回5 MB字符串.NET應用程序。
我要求有人可以幫我解決這個問題。 請提前發現怪才下面
using (SqlCommand command = new SqlCommand(Source.GetExportRecordSP, Connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@CandidateRecordID ", SqlDbType.NVarChar, 32)).Value = record;
try
{
if (Connection.State != ConnectionState.Open)
{
Connection.Open();
}
using (SqlDataReader reader = command.ExecuteReader())
{
if(reader.Read())
{
xmlRecord = new XmlDocument();
xmlRecord.LoadXml(reader.GetString(0));
}
}
}
catch (Exception Ex)
{
Logging.WriteError(string.Format("Error while retrieving the Record \"{0}\" details from Database. Exception: {1} ", Ex.ToString()));
throw;
}
}
感謝代碼。
'varchar(max)'應該能夠返回超過8kb ......你的.NET代碼是什麼樣的?我的猜測是,這個問題是在你的數據訪問層,而不是你的存儲過程。 – 2012-02-22 19:43:13
同意@Michael,發佈您的.Net代碼。 – sisdog 2012-02-23 03:15:38
謝謝米哈爾,請找到下面的代碼, – Sadhu 2012-02-23 06:59:29