Databases Reference
In-Depth Information
Try It Out: Retrieving Text Data
To retrieve data from text columns, follow these steps:
1. Add a C# Console Application project named RetrieveText to the solution.
2. Rename Program.cs to RetrieveText.cs , and replace the code with that in List-
ing 18-5.
Listing 18-5. RetrieveText.cs
using System;
using System.Data;
using System.Data.SqlClient;
namespace RetrieveText
{
public class RetrieveText
{
string textFile = null;
char[] textChars = null;
SqlConnection conn = null;
SqlCommand cmd = null;
SqlDataReader dr = null;
public RetrieveText()
{
// create connection
conn = new SqlConnection(@"
data source = .\sqlexpress;
integrated security = true;
initial catalog = tempdb;
");
// create command
cmd = new SqlCommand(@"
select
textfile,
textdata
from
texttable
", conn);
Search WWH ::




Custom Search