Databases Reference
In-Depth Information
if (dr.Read())
{
// get file name
textFile = dr.GetString(0);
Console.WriteLine("------ start of file:");
Console.WriteLine(textFile);
textSize = dr.GetChars(1, 0, null, 0, 0);
Console.WriteLine("--- size of text: {0} characters -----",
textSize);
Console.WriteLine("--- first 100 characters in text -----");
charsRead = dr.GetChars(1, 0, textChars, 0, 100);
Console.WriteLine(new String(textChars));
Console.WriteLine("--- last 100 characters in text -----");
charsRead = dr.GetChars(1, textSize - 100, textChars, 0, 100);
Console.WriteLine(new String(textChars));
return true;
}
else
{
return false;
}
Rather than print the whole file, you display the first 100 bytes, using GetChars() to
extract a substring. You do the same thing with the last 100 characters.
Otherwise, this program is like any other that retrieves and displays database charac-
ter data.
Summary
In this chapter, you explored SQL Server's text and binary data types. You also practiced
storing and retrieving binary and text data using data types for SQL Server large objects
and ADO.NET.
In the next chapter, you will learn about the most exciting feature of .NET 3.5: Lan-
guage Integrated Query (LINQ).
Search WWH ::




Custom Search