Databases Reference
In-Depth Information
Listing 18-4. LoadText.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.IO;
namespace LoadText
{
class LoadText
{
static string fileName =
@"C:\Documents and Settings\Administrator\My Documents\"
+ @"Visual Studio Codename å
Orcas\Projects\Chapter18\LoadText\LoadText.cs";
SqlConnection conn = null;
SqlCommand cmd = null;
static void Main()
{
LoadText loader = new LoadText();
try
{
// get text file
loader.GetTextFile(fileName);
// open connection
loader.OpenConnection();
// create command
loader.CreateCommand();
// create table
loader.CreateTextTable();
// prepare insert command
loader.PrepareInsertTextFile();
// load text file
loader.ExecuteInsertTextFile(fileName);
Console.WriteLine(
"Loaded {0} into texttable.", fileName
);
}
catch (SqlException ex)
Search WWH ::




Custom Search